Skip to content

Craft Anything: understand how any software works, and craft your own.

Rust

The Linux AppImage runs its CLI with --cli or through a link named craft-anything-cli (#725)

BFlat01c2634199a7
diff --git a/README.md b/README.md
index c8714387..6aad568b 100644
--- a/README.md
+++ b/README.md
@@ -303,6 +303,10 @@ Privacy & Security → Open Anyway.
RISC-V (riscv64): `craft-anything-<ver>-linux-riscv64.tar.gz`, a tarball only.
+The AppImage carries the CLI too: run `<AppImage> --cli <command>` (for example
+`<AppImage> --cli mcp` for an MCP client), or make a link to the AppImage named
+`craft-anything-cli` and run that.
+
### FreeBSD
| Build | File |
diff --git a/packaging/linux/AppRun b/packaging/linux/AppRun
index 30d313ab..c3004f2f 100755
--- a/packaging/linux/AppRun
+++ b/packaging/linux/AppRun
@@ -68,5 +68,17 @@ integrate() {
done
}
+# The command-line tool ships beside the app but nothing puts it on PATH, and the launcher renames
+# the AppImage on every update (#723). `<AppImage> --cli …` runs it, and so does a symlink to the
+# AppImage named `craft-anything-cli` (the runtime passes the name it was started by as $ARGV0).
+# It writes nothing to the desktop: a CLI or MCP run isn't a launch of the app.
+case "${ARGV0:-}" in
+ *craft-anything-cli) exec "$APPDIR/usr/bin/craft-anything-cli" "$@" ;;
+esac
+if [ "${1:-}" = "--cli" ]; then
+ shift
+ exec "$APPDIR/usr/bin/craft-anything-cli" "$@"
+fi
+
integrate
exec "$APPDIR/usr/bin/craft-anything" "$@"
diff --git a/packaging/linux/apprun-test.sh b/packaging/linux/apprun-test.sh
index 387124eb..0fc7a561 100755
--- a/packaging/linux/apprun-test.sh
+++ b/packaging/linux/apprun-test.sh
@@ -22,6 +22,8 @@ mkdir -p "$APPDIR/usr/share/icons"
cp -R "$ROOT/assets/app-icon/hicolor" "$APPDIR/usr/share/icons/"
printf '#!/bin/sh\necho "stub: $*"\n' >"$APPDIR/usr/bin/craft-anything"
chmod +x "$APPDIR/usr/bin/craft-anything"
+printf '#!/bin/sh\necho "cli: $*"\n' >"$APPDIR/usr/bin/craft-anything-cli"
+chmod +x "$APPDIR/usr/bin/craft-anything-cli"
APPIMAGE="$TMP/craft-anything test.AppImage" # spaces on purpose: Exec must stay quoted
: >"$APPIMAGE"
@@ -95,4 +97,19 @@ out="$(APPIMAGE="$odd" "$APPDIR/AppRun" x)" || fail "launch with an odd path exi
[ "$out" = "stub: x" ] || fail "odd path: $out"
[ ! -e "$XDG_DATA_HOME" ] || fail "integrated an AppImage path that needs escaping"
-echo "AppRun desktop integration ok"
+# 10. `--cli` runs the bundled CLI with the rest of the arguments, and integrates nothing (#723).
+rm -rf "$XDG_DATA_HOME"
+out="$("$APPDIR/AppRun" --cli mcp --project "a b.cany")" || fail "--cli exited non-zero"
+[ "$out" = "cli: mcp --project a b.cany" ] || fail "--cli not routed to the CLI: $out"
+[ ! -e "$XDG_DATA_HOME" ] || fail "a CLI run integrated the desktop entry"
+
+# 11. Started through a link named craft-anything-cli ($ARGV0), every argument goes to the CLI.
+out="$(ARGV0="/home/u/.local/bin/craft-anything-cli" "$APPDIR/AppRun" --version)" || fail "ARGV0 route exited non-zero"
+[ "$out" = "cli: --version" ] || fail "ARGV0 not routed to the CLI: $out"
+[ ! -e "$XDG_DATA_HOME" ] || fail "an ARGV0 CLI run integrated the desktop entry"
+
+# 12. Any other name, or --cli later on the line, still starts the app.
+out="$(ARGV0="craft-anything" "$APPDIR/AppRun" open --cli)" || fail "app launch exited non-zero"
+[ "$out" = "stub: open --cli" ] || fail "app launch routed to the CLI: $out"
+
+echo "AppRun desktop integration and CLI routing ok"