//! Command line entry: dispatch table, usage text and exit codes. //! //! Exit codes are fixed across every command: 0 success, 1 refusal or error, //! 2 bad usage. Each command returns its code; nothing else calls `exit`. module cli // Read from VERSION at build time, so the binary and the manifest cannot drift. pub const version = $embed_file('../../VERSION').to_string().trim_space() const usage = 'koh ${version} — one SQLite file per repo, one line of history usage: koh [options] save, checkpoint, status, log, diff undo, revert, load flag, pluck, peek offer, steal, remote init, doctor, strip, migrate run "koh help " for one command\'s options.' pub fn run(args []string) int { if args.len < 2 { eprintln(usage) return 2 } match args[1] { '--version', '-v' { println('koh ${version}') return 0 } '--help', '-h', 'help' { println(usage) return 0 } else { eprintln('koh: unknown command "${args[1]}"') eprintln('run "koh --help" for the command list') return 2 } } }