123456module cli789pub const version = $embed_file('../../VERSION').to_string().trim_space()1011const usage = 'koh ${version} — one SQLite file per repo, one line of history1213usage: koh <command> [options]1415everyday16 save <message> [--agent <m>] [--session <s>] snapshot the working tree17 checkpoint <message> save, even with no changes18 status what changed since the last save19 log [--since <expr>] [--session <s>] the line, newest first20 diff [<id>] [<id1> <id2>] [--session last|<s>] unified diff2122going back23 undo [n] [--session] step back n saves24 revert discard unsaved changes25 load <id> | --checkpoint restore any save2627occasional28 flag <id> [--reason "..."] | --clear <id> mark a save unsafe29 pluck <id> [--reverse] [--dry-run] [path...] apply one save, or its inverse30 peek <id> restore a save into a temp folder3132setup and care33 init create .koh here34 doctor [--backup <path>] integrity check and cleanup35 strip <path> [--save <id>] remove a path from history3637 saves / checkpoints open the history view on that tab38 --json on any command that prints data, --yes to skip a confirm prompt'3940pub fn run(argv []string) int {41 if argv.len < 2 {42 eprintln(usage)43 return 244 }45 rest := argv[2..]46 match argv[1] {47 '--version', '-v' {48 println('koh ${version}')49 return 050 }51 '--help', '-h', 'help' {52 println(usage)53 return 054 }55 'init' {56 return cmd_init(rest)57 }58 'save' {59 return cmd_save(rest, false)60 }61 'checkpoint' {62 return cmd_save(rest, true)63 }64 'status' {65 return cmd_status(rest)66 }67 'log' {68 return cmd_log(rest)69 }70 'saves' {71 return cmd_saves(rest)72 }73 'checkpoints' {74 return cmd_checkpoints(rest)75 }76 'diff' {77 return cmd_diff(rest)78 }79 'undo' {80 return cmd_undo(rest)81 }82 'revert' {83 return cmd_revert(rest)84 }85 'load' {86 return cmd_load(rest)87 }88 'flag' {89 return cmd_flag(rest)90 }91 'pluck' {92 return cmd_pluck(rest)93 }94 'peek' {95 return cmd_peek(rest)96 }97 'doctor' {98 return cmd_doctor(rest)99 }100 'strip' {101 return cmd_strip(rest)102 }103 else {104 eprintln(' koh: unknown command "${argv[1]}"')105 eprintln(' run "koh --help" for the command list')106 return 2107 }108 }109}