]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/commitdiff
Merge pull request #23 from fourchettes/fix/dash
authorb3nj5m1n <47924309+b3nj5m1n@users.noreply.github.com>
Sun, 15 May 2022 10:38:41 +0000 (12:38 +0200)
committerGitHub <noreply@github.com>
Sun, 15 May 2022 10:38:41 +0000 (12:38 +0200)
xdg-ninja: change jq json source

README.md
programs/sdkman.json [new file with mode: 0644]
programs/volta.json [new file with mode: 0644]
xdg-ninja.sh

index d4e3349315d58fe4a047293e1a7dc431e76fa39a..d97b7e83db37051324de0d2d9bdfde8d7b106aae 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ This will run every test in the default configuration.
 
 ### Optional
 
-- [glow](https://repology.org/project/glow/packages) for rendering markdown in the terminal
+- [glow](https://repology.org/project/glow/packages) for rendering markdown in the terminal ([bat](https://repology.org/project/bat-cat/packages) can be used as a fallback, but glows output is clearer and therefore recommended)
 - [cabal](https://repology.org/project/cabal/packages) for compiling the helper program for creating configurations
 
 ## Configuration
diff --git a/programs/sdkman.json b/programs/sdkman.json
new file mode 100644 (file)
index 0000000..dd6d053
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "files": [
+        {
+            "path": "$HOME/.sdkman",
+            "movable": true,
+            "help": "Export the following environment variables:\n\n```bash\nexport SDKMAN_DIR=\"$XDG_DATA_HOME\"/sdkman\n```\n"
+        }
+    ],
+    "name": "sdkman"
+}
diff --git a/programs/volta.json b/programs/volta.json
new file mode 100644 (file)
index 0000000..c4a0bb4
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "files": [
+        {
+            "path": "$HOME/.volta",
+            "movable": true,
+            "help": "Export the following environment variables:\n\n```bash\nexport VOLTA_HOME=\"$XDG_DATA_HOME\"/volta\n```\n"
+        }
+    ],
+    "name": "volta"
+}
index d3e43d801a1f181122e8ede1bf56de607cf2005d..56b970e1c96d28649a468c28d778a0a38c6063d1 100755 (executable)
@@ -1,12 +1,18 @@
 #!/usr/bin/env sh
 # shellcheck disable=SC2016
 
-USE_GLOW=true
-if ! command -v glow >/dev/null 2>/dev/null; then
-    printf "Glow not found, markdown rendering not available.\n"
+USE_GLOW=false
+USE_BAT=false
+if command -v glow >/dev/null 2>/dev/null; then
+    USE_GLOW=true
+elif command -v bat >/dev/null 2>/dev/null; then
+    USE_BAT=true
+    printf "Glow not found, markdown rendering will be done by bat.\n"
+    printf "Install glow for easier reading & copy-paste.\n"
+else
+    printf "Glow or bat not found, markdown rendering not available.\n"
     printf "Output will be raw markdown and might look weird.\n"
     printf "Install glow for easier reading & copy-paste.\n"
-    USE_GLOW=false
 fi
 
 unalias -a
@@ -122,9 +128,11 @@ log() {
 
     HELP)
         if $USE_GLOW; then
-            printf "%s" "$HELP" | glow -
+            printf "%s\n" "$HELP" | glow -
+        elif $USE_BAT; then
+            printf "%s\n" "$HELP" | bat -pp -f --language markdown
         else
-            printf "%s" "$HELP"
+            printf "%s\n" "$HELP"
         fi
         ;;