-
Notifications
You must be signed in to change notification settings - Fork 0
CLI Reference
Kartend is primarily a GUI app, but it accepts a small set of
command-line options for headless workflows: opening a specific
collection on launch, importing or exporting .kart packages from a
script, and the standard Qt help / version flags.
For environment variables (logging, diagnostics) see Logging & Diagnostics.
kartend [options]
| Option | Form | Description |
|---|---|---|
--help / -h
|
flag | Print usage and exit. |
--version / -v
|
flag | Print version and exit. |
-c <name> / --collection <name>
|
takes value | Open the named collection on launch (bypasses [General] startupCollection). Falls back to the default if unknown. |
--import-kart <path> |
takes value | Import a .kart package headlessly. Implies exit on completion. |
--to <dir> |
takes value | Destination directory for --import-kart. Default: ~/imported-kart. |
--on-conflict <policy> |
takes value | Conflict policy for --import-kart: skip (default) / overwrite / merge. |
--export-kart <name> |
takes value | Export the named collection headlessly. Implies exit on completion. |
--export-out <path> |
takes value | Output path for --export-kart. Required when exporting. |
Standard Qt options (--platform, --style, --stylesheet, etc.) are
also accepted but rarely used in practice. See the Qt documentation
for the full list.
| Code | Meaning |
|---|---|
0 |
Success — including a normal interactive launch ending with Ctrl+Q or window-close. |
1 |
Generic error (rarely used; reserved). |
2 |
Command-line argument error or headless operation failed (collection not found, missing required arg, kart read/write error). |
42 |
Sanitizer / smoke-test exit code (see KARTEND_SMOKE_TEST_EXIT_MS). |
kartend --collection "Films"
kartend -c "Albums"Equivalent to setting [General] startupCollection=Films, but
applies for one launch only without modifying the config file.
If the named collection doesn't exist, Kartend logs a warning and falls back to the configured default.
kartend --export-kart "Films" --export-out ~/backups/films.kartBoth flags required. Exit 0 on success; 2 on failure (collection
not found, output path unwritable, etc.). The console gets a one-line
summary on success.
kartend --import-kart ~/backups/gb.kartDefault destination: ~/imported-kart. Default conflict policy:
skip. Override with --to and --on-conflict:
kartend --import-kart ~/backups/films.kart \
--to ~/Videos/Films \
--on-conflict overwrite| Policy | Effect on name collision |
|---|---|
skip |
Don't import the conflicting collection. Existing one preserved. |
overwrite |
Replace the existing collection. |
merge |
Combine — existing fields stay, imported fills in blanks. |
See Backup & Migration → Conflict policies for the full semantics.
# Use a specific Qt platform plugin (rarely needed)
QT_QPA_PLATFORM=wayland kartend
# Force a specific Qt style
kartend -style fusion
# Use offscreen for testing (no display required)
QT_QPA_PLATFORM=offscreen kartendQT_QPA_PLATFORM=offscreen is what CI uses for unit and integration
tests — see testing.md.
#!/bin/sh
set -euo pipefail
DATE=$(date +%Y-%m-%d)
DEST=~/backups/kartend/$DATE
mkdir -p "$DEST"
# Pull collection names from the config file
collections=$(awk -F'[][]' '/^\[/ && !/^\[General\]/ {print $2}' \
~/.config/kartend/kartend.cfg)
while IFS= read -r c; do
[ -z "$c" ] && continue
out="$DEST/${c// /_}.kart"
kartend --export-kart "$c" --export-out "$out"
done <<< "$collections"
echo "Backup complete in $DEST"A daily-cron invocation produces a dated tree of .kart exports.
#!/bin/sh
set -euo pipefail
for k in ~/restore/*.kart; do
kartend --import-kart "$k" --to "$HOME/Media" --on-conflict skip
doneIterates through .kart files; skip any that conflict (so reruns are
idempotent — already-present collections are left alone).
If you want a launcher icon that goes straight into a specific collection:
[Desktop Entry]
Name=Kartend — Films
Exec=kartend --collection "Films"
Icon=io.github.EtherAura.Kartend
Type=Application
Categories=Utility;Qt;Drop in ~/.local/share/applications/. Shows up in your application
menu as a separate entry.
There's no --validate flag today. Closest workaround: import to a
throwaway directory with skip policy:
TMP=$(mktemp -d)
kartend --import-kart suspect.kart --to "$TMP" --on-conflict skip
status=$?
echo "Exit: $status"
rm -rf "$TMP"Exit 0 means the package was readable.
Headless invocations still read your config and database from
~/.config/kartend/ and ~/.local/share/kartend/. To run against a
sandbox HOME:
HOME=/tmp/kartend-test kartend --import-kart suspect.kartUseful for dry-runs that don't touch your real configuration.
- No
--validate/ dry-run mode. - No bulk export ("export all collections").
- No JSON output for stats / collection listings (everything is imperative).
- No flag to skip the splash screens for headless.
- No
--config <path>flag (Kartend honorsXDG_CONFIG_HOMEif you want to direct the config search; that's the workaround).
For any of these, file a feature request — the parser is QCommandLineParser based and cheap to extend.
- Parsing: src/core/main.cpp. Uses
QCommandLineParser::process()so the standard Qt help / version / unknown-option semantics apply. - A unit-testable parser shim lives in
src/utils/app/cliargs.cpp — the inline
parser in
main.cppmirrors it but usesprocess()for real CLI behavior. - Adding a new flag:
- Add the
QCommandLineOptiondefinition tomain.cpp. - Mirror it in
cliargs.cppso it can be unit-tested without spinning upQApplication. - Wire the new behavior (call into the relevant manager).
- Add a row to the table at the top of this page and a worked example below it.
- Add the
- Headless export entry point:
KartManager::exportKartCollection. - Headless import entry point:
KartManager::importKartHeadless. - Tests for arg parsing:
tests/utils/test_cliargs.cpp.