]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/blobdiff - xdg-ninja.sh
Update subversion.json
[xdg-ninja.git] / xdg-ninja.sh
index c7633c07ff94da6e236b0e9f979fde93cd2c85f8..820c8e95e548c80eaaec36f48242e90f0b84e968 100755 (executable)
@@ -9,6 +9,45 @@ fi
 
 unalias -a
 
+HELPSTRING="""\
+
+
+    \e[37;45;1mxdg-ninja\e[0m
+
+    \e[1;3mCheck your \$HOME for unwanted files.\e[1;0m
+
+    ────────────────────────────────────
+
+    \e[3m--help\e[0m              \e[1mThis help menu\e[0m
+    \e[3m-h\e[0m
+
+    \e[3m--no-skip-ok\e[0m        \e[1mDisplay messages for all files checked (verbose)\e[0m
+    \e[3m-v\e[0m
+
+    \e[3m--skip-ok\e[0m           \e[1mDon't display anything for files that do not exist (default)\e[0m
+
+"""
+
+SKIP_OK=true
+for i in "$@" ; do
+    if [[ $i == "--help" ]] || [[ $i == "-h" ]] ; then
+        echo -e "$HELPSTRING"
+        exit
+    elif [[ $i == "--skip-ok" ]] ; then
+        SKIP_OK=true
+    elif [[ $i == "--no-skip-ok" ]] ; then
+        SKIP_OK=false
+    elif [[ $i == "-v" ]] ; then
+        SKIP_OK=false
+    fi
+done
+
+if ! command -v jq &> /dev/null
+then
+    echo "jq is needed to run this script, but it wasn't found. Please install it to be able to use this script."
+    exit
+fi
+
 ERR=0
 WARN=1
 INFO=2
@@ -60,7 +99,9 @@ log() {
             ;;
 
         SUCS)
-            printf "[\e[1;32m$NAME\e[1;0m]: \e[1;3m$FILENAME\e[1;0m\n"
+            if [ "$SKIP_OK" = false ]; then
+                printf "[\e[1;32m$NAME\e[1;0m]: \e[1;3m$FILENAME\e[1;0m\n"
+            fi
             ;;
 
         HELP)
@@ -112,7 +153,6 @@ check_program() {
     INPUT=$1
 
     NAME=$(echo "$INPUT" | jq -r .name)
-
     
 
     while IFS= read -r file; do
@@ -122,9 +162,15 @@ check_program() {
 
 # Loops over all files in the programs/ directory and calls check_program
 enumerate_programs() {
-    for prog_filename in "./programs/*"; do
+    echo -e "\e[1;3mStarting to check your \e[1;36m\$HOME.\e[1;0m"
+    echo -e ""
+    for prog_filename in ./programs/*; do
         check_program "$(cat $prog_filename)"
     done
+    echo -e "\e[1;3mDone checking your \e[1;36m\$HOME.\e[1;0m"
+    echo -e ""
+    echo -e "\e[3mIf you have files in your \e[1;36m\$HOME\e[1;0m that shouldn't be there, but weren't recognised by xdg-ninja, please consider creating a configuration file for it and opening a pull request on github.\e[1;0m"
+    echo -e ""
 }
 
 enumerate_programs