Also switch from getopts to clap
EBE4NGXWTXMGB6B7M4AWJRMVQE2QYR2GODPPRWE67RKQLFAW7KBAC
QWLMNP5FOCONNJDNVKZFHJIM7WHLF7QCJI67YSV5VT2SXEOPZ6TQC
XJLSNX3LGZPQ5OFKG57C3H7P5VRSGHYQU3IKXEPRQR7LBKPU5DEAC
TQBJZLD7Q223IFEBR7SU4FJWPWQWVBCSRPYYYEHXNSDM6DC7UWRAC
W7HZ5VFMEFVJIPYZJXOSMWTQ7DOZOOHT4QZTMDCT63AKIWB3TCZQC
IKID4WPYXHXUMGHLHTU4ADY6WNJNZM2OAHQ5DYNDLB2SFFECR4SAC
ATRA7XTTN62JZQOI7A4JI3Z7L3XVTAEEW2U4AX6UQKEQ6USOXQDQC
UFSP7C7B2ERFJ2XVVVNXGZRXUEMFSMRABC5YXXLK6ONMFG6QBNHAC
YNZMKRJDWYOQ3R3XHA2G47YG2SDI7FT7AEXH3OLB3BJGB6ALTRQAC
R3XMFPCYGXT5CNHYRNVZDGD2TDTCK6XGQ55SPJW56UEQQNV4R64AC
OZUZ5H6DJUXJ2MEHQK6FQ7LTSPUHHGZSFZ3SPBV26A2KBE4TQKQQC
FIIUZR4LJOB5DPB4CBMPJHMO7C5Q4ZINUVM52UK6SIM5WM7R7ZLAC
GKLDTVAKBFKWS3JZVTWJAWYUNPEIUMK6FW77IRD7J26NAVQ52CKQC
#[derive(Parser)]
struct Cli {
#[arg(long, default_value = ".", help = "repository path")]
repo: String,
#[arg(long, default_value = "main", help = "channel to export")]
channel: String,
#[arg(long, help = "branch name in git")]
branch: Option<String>,
#[arg(long, help = "file to import and export marks")]
marks: Option<String>,
#[arg(
long = "progress-interval",
help = "report progress every N commits",
value_name = "N"
)]
progress_interval: Option<i32>,
}
let args: Vec<String> = env::args().collect();
let mut opts = Options::new();
opts.optopt("r", "repo", "repository path", "PATH");
opts.optopt("c", "channel", "channel to export", "NAME");
opts.optopt("b", "branch", "branch name in git", "NAME");
opts.optopt(
"m",
"marks",
"file to import and export marks",
"MARKS-FILE",
);
let matches = opts.parse(&args[1..]).unwrap();
let repo_path = matches.opt_str("r").unwrap_or(".".to_string());
let channel = matches.opt_str("c").unwrap_or("main".to_string());
let cli = Cli::parse();
let mut repo = Repository::load(&repo_path).unwrap();
let mut stream = FastExportStream::new(matches.opt_str("b").unwrap_or(channel.to_string()));
let mut repo = Repository::load(&cli.repo).unwrap();
let mut stream = FastExportStream::new(cli.branch.unwrap_or(cli.channel.to_string()));
clap = { version = "4.2.3", features = ["derive"] }
]
[[package]]
name = "anstream"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is-terminal",
"utf8parse",
name = "anstyle"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
[[package]]
name = "anstyle-parse"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "anstyle-wincon"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd"
dependencies = [
"anstyle",
"windows-sys 0.48.0",
]
[[package]]
]
[[package]]
name = "clap"
version = "4.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f9152d70e42172fdb87de2efd7327160beee37886027cf86f30a233d5b30b4"
dependencies = [
"clap_builder",
"clap_derive",
"once_cell",
]
[[package]]
name = "clap_builder"
version = "4.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e067b220911598876eb55d52725ddcc201ffe3f0904018195973bc5b012ea2ca"
dependencies = [
"anstream",
"anstyle",
"bitflags",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.15",
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]]