//! Refuse repository commands until a Koh 2 repository has been migrated. module cli import os pub fn needs_migration(argv []string) bool { if argv.len < 2 || argv[1] in ['migrate', 'man', 'help', '--help', '-h', '--version', '-v', 'remote', 'update'] { return false } return inside_koh2_repo(os.getwd()) } // inside_koh2_repo looks upward for a `.koh` that is a directory. A `.koh` // file is Koh 3's. fn inside_koh2_repo(start string) bool { mut dir := os.real_path(start) for { path := os.join_path(dir, '.koh') if os.is_dir(path) { return true } if os.is_file(path) { return false } parent := os.dir(dir) if parent == dir || parent == '' { return false } dir = parent } return false }