123module cli45import os6import src.history7import src.snapshot8import src.storage910pub fn repo_root() !string {11 root := storage.find_root(os.getwd()) or {12 return error('not inside a koh repo — run "koh init" here, or "koh steal <name>"')13 }14 return root15}1617pub fn open_store() !storage.Store {18 root := repo_root()!19 return storage.open(root)!20}212223pub fn tree_of(store &storage.Store, save_id string) !snapshot.Tree {24 return snapshot.Tree{25 files: history.files_of(store, save_id)!26 }27}2829pub fn working_tree(store &storage.Store) !snapshot.Tree {30 return snapshot.Tree{31 root: store.root32 files: snapshot.walk(store, store.root, snapshot.load(store.root))!33 }34}3536pub fn label(store &storage.Store, id string) string {37 save := history.by_id(store, id) or { return id }38 return '${save.id} ${save.message}'39}