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 save2627sync28 remote choose S3 or a folder, once per machine29 offer send new saves to the remote30 steal [<name>] [--list] [--mine|--theirs] bring in saves from the remote3132occasional33 flag <id> [--reason "..."] | --clear <id> mark a save unsafe34 pluck <id> [--reverse] [--dry-run] [path...] apply one save, or its inverse35 peek <id> restore a save into a temp folder3637setup and care38 init create .koh here39 doctor [--backup <path>] integrity check and cleanup40 strip <path> [--save <id>] remove a path from history4142 migrate [--lane dev|main] convert a Koh 2 repo here43 man [<command>] the manual, built in44 saves / checkpoints open the history view on that tab45 --json on any command that prints data, --yes to skip a confirm prompt'4647pub fn run(argv []string) int {48 if argv.len < 2 {49 eprintln(usage)50 return 251 }52 hand_over(argv)53 rest := argv[2..]54 match argv[1] {55 '--version', '-v' {56 println('koh ${version}')57 return 058 }59 '--help', '-h' {60 println(usage)61 return 062 }63 'init' {64 return cmd_init(rest)65 }66 'save' {67 return cmd_save(rest, false)68 }69 'checkpoint' {70 return cmd_save(rest, true)71 }72 'status' {73 return cmd_status(rest)74 }75 'log' {76 return cmd_log(rest)77 }78 'saves' {79 return cmd_saves(rest)80 }81 'checkpoints' {82 return cmd_checkpoints(rest)83 }84 'diff' {85 return cmd_diff(rest)86 }87 'undo' {88 return cmd_undo(rest)89 }90 'revert' {91 return cmd_revert(rest)92 }93 'load' {94 return cmd_load(rest)95 }96 'flag' {97 return cmd_flag(rest)98 }99 'pluck' {100 return cmd_pluck(rest)101 }102 'peek' {103 return cmd_peek(rest)104 }105 'doctor' {106 return cmd_doctor(rest)107 }108 'strip' {109 return cmd_strip(rest)110 }111 'remote' {112 return cmd_remote(rest)113 }114 'offer' {115 return cmd_offer(rest)116 }117 'steal' {118 return cmd_steal(rest)119 }120 'migrate' {121 return cmd_migrate(rest)122 }123 'man', 'help' {124 return cmd_man(rest)125 }126 else {127 eprintln(' koh: unknown command "${argv[1]}"')128 eprintln(' run "koh --help" for the command list')129 return 2130 }131 }132}