Navigate a directory full of directories, identifying repos and worktrees
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove subcommands, make list the default behavior

rektide 5aa3a786 d36504a5

+10 -28
+10 -28
src/main.rs
··· 1 1 use std::fs; 2 2 use std::path::{Path, PathBuf}; 3 3 4 - use clap::{Parser, Subcommand}; 4 + use clap::Parser; 5 5 use serde::Serialize; 6 6 7 7 mod detect; ··· 11 11 }; 12 12 13 13 #[derive(Parser)] 14 - #[command(name = "is-tree")] 15 - struct Cli { 16 - #[command(subcommand)] 17 - command: Option<Commands>, 18 - } 19 - 20 - #[derive(Subcommand)] 21 - enum Commands { 22 - #[command(about = "List repository info for directories")] 23 - List(ListArgs), 24 - } 25 - 26 - #[derive(Parser)] 27 - #[command(after_long_help = " 14 + #[command( 15 + name = "is-tree", 16 + after_long_help = " 28 17 DETAILED OPTIONS: 29 18 30 19 --filter <TYPES> ··· 61 50 --format '{directory} - {status} ({workparent})' 62 51 --format '{directory} ({variant})' 63 52 --format all 64 - ")] 65 - struct ListArgs { 53 + " 54 + )] 55 + struct Cli { 66 56 #[arg(short, long)] 67 57 all: bool, 68 58 ··· 116 106 117 107 fn main() { 118 108 let cli = Cli::parse(); 119 - 120 - match cli.command { 121 - None => { 122 - eprintln!("Usage: is-tree <command>"); 123 - eprintln!("Commands: list"); 124 - std::process::exit(1); 125 - } 126 - Some(Commands::List(args)) => run_list(args), 127 - } 109 + run_list(cli); 128 110 } 129 111 130 - fn run_list(args: ListArgs) { 112 + fn run_list(args: Cli) { 131 113 let filters = parse_filters(args.filter.as_deref()); 132 114 let sort_specs = parse_sort_specs(args.sort.as_deref()); 133 115 let format_str = args.format.as_deref().map(resolve_format_shortcuts); ··· 139 121 .map(|p| current_dir.join(p)) 140 122 .collect() 141 123 } else if args.directories.is_empty() { 142 - eprintln!("Usage: is-tree list <directory> [directories...] | --all"); 124 + eprintln!("Usage: is-tree <directory> [directories...] | --all"); 143 125 std::process::exit(1); 144 126 } else { 145 127 args.directories