commands: split up definition of Clap App to help rustfmt

It seems the definition had gotten too large for rustfmt.
This commit is contained in:
Martin von Zweigbergk 2020-12-26 18:59:06 -08:00
parent 06401fc30d
commit 09e474a05a

View file

@ -260,21 +260,7 @@ fn update_checkout_after_rewrite(ui: &mut Ui, tx: &mut Transaction) {
} }
fn get_app<'a, 'b>() -> App<'a, 'b> { fn get_app<'a, 'b>() -> App<'a, 'b> {
App::new("Jujube") let init_command = SubCommand::with_name("init")
.global_setting(clap::AppSettings::ColoredHelp)
.version("0.0.1")
.author("Martin von Zweigbergk <martinvonz@google.com>")
.about("My source control tool")
.arg(
Arg::with_name("repository")
.long("repository")
.short("R")
.takes_value(true)
.default_value("."),
)
.arg(Arg::with_name("at_op").long("at-operation").alias("at-op").takes_value(true))
.subcommand(
SubCommand::with_name("init")
.about("initialize a repo") .about("initialize a repo")
.arg(Arg::with_name("destination").index(1).default_value(".")) .arg(Arg::with_name("destination").index(1).default_value("."))
.arg( .arg(
@ -282,21 +268,15 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.long("git-store") .long("git-store")
.takes_value(true) .takes_value(true)
.help("path to a .git backing store"), .help("path to a .git backing store"),
), );
) let checkout_command = SubCommand::with_name("checkout")
.subcommand(
SubCommand::with_name("checkout")
.alias("co") .alias("co")
.about("update the working copy to another commit") .about("update the working copy to another commit")
.arg(Arg::with_name("revision").index(1).required(true)), .arg(Arg::with_name("revision").index(1).required(true));
) let files_command = SubCommand::with_name("files")
.subcommand(
SubCommand::with_name("files")
.about("list files") .about("list files")
.arg(rev_arg()), .arg(rev_arg());
) let diff_command = SubCommand::with_name("diff")
.subcommand(
SubCommand::with_name("diff")
.about("show modified files") .about("show modified files")
.arg( .arg(
Arg::with_name("summary") Arg::with_name("summary")
@ -304,21 +284,18 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.short("s") .short("s")
.help("show only the diff type (modified/added/removed)"), .help("show only the diff type (modified/added/removed)"),
) )
.arg(Arg::with_name("revision") .arg(
Arg::with_name("revision")
.long("revision") .long("revision")
.short("r") .short("r")
.takes_value(true) .takes_value(true),
) )
.arg(Arg::with_name("from").long("from").takes_value(true)) .arg(Arg::with_name("from").long("from").takes_value(true))
.arg(Arg::with_name("to").long("to").takes_value(true)), .arg(Arg::with_name("to").long("to").takes_value(true));
) let status_command = SubCommand::with_name("status")
.subcommand(
SubCommand::with_name("status")
.alias("st") .alias("st")
.about("show repo status"), .about("show repo status");
) let log_command = SubCommand::with_name("log")
.subcommand(
SubCommand::with_name("log")
.about("show commit history") .about("show commit history")
.arg( .arg(
Arg::with_name("template") Arg::with_name("template")
@ -327,10 +304,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true), .takes_value(true),
) )
.arg(Arg::with_name("all").long("all")) .arg(Arg::with_name("all").long("all"))
.arg(Arg::with_name("no-graph").long("no-graph")), .arg(Arg::with_name("no-graph").long("no-graph"));
) let obslog_command = SubCommand::with_name("obslog")
.subcommand(
SubCommand::with_name("obslog")
.about("show how a commit has evolved") .about("show how a commit has evolved")
.arg(rev_arg()) .arg(rev_arg())
.arg( .arg(
@ -339,52 +314,34 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.short("T") .short("T")
.takes_value(true), .takes_value(true),
) )
.arg(Arg::with_name("no-graph").long("no-graph")), .arg(Arg::with_name("no-graph").long("no-graph"));
) let describe_command = SubCommand::with_name("describe")
.subcommand(
SubCommand::with_name("describe")
.about("edit the commit description") .about("edit the commit description")
.arg(rev_arg()) .arg(rev_arg())
.arg(Arg::with_name("text").long("text").takes_value(true)) .arg(Arg::with_name("text").long("text").takes_value(true))
.arg(Arg::with_name("stdin").long("stdin")), .arg(Arg::with_name("stdin").long("stdin"));
) let close_command = SubCommand::with_name("close")
.subcommand(
SubCommand::with_name("close")
.about("mark a commit closed, making new work go into a new commit") .about("mark a commit closed, making new work go into a new commit")
.arg(rev_arg()), .arg(rev_arg());
) let open_command = SubCommand::with_name("open")
.subcommand(
SubCommand::with_name("open")
.about("mark a commit open, making new work be added to it") .about("mark a commit open, making new work be added to it")
.arg(rev_arg()), .arg(rev_arg());
) let duplicate_command = SubCommand::with_name("duplicate")
.subcommand(
SubCommand::with_name("duplicate")
.about("create a copy of the commit with a new change id") .about("create a copy of the commit with a new change id")
.arg(rev_arg()), .arg(rev_arg());
) let prune_command = SubCommand::with_name("prune")
.subcommand(
SubCommand::with_name("prune")
.about("create an empty successor of a commit") .about("create an empty successor of a commit")
.arg(rev_arg()), .arg(rev_arg());
) let new_command = SubCommand::with_name("new")
.subcommand(
SubCommand::with_name("new")
.about("create a new, empty commit") .about("create a new, empty commit")
.arg(rev_arg()), .arg(rev_arg());
) let squash_command = SubCommand::with_name("squash")
.subcommand(
SubCommand::with_name("squash")
.about("squash a commit into its parent") .about("squash a commit into its parent")
.arg(rev_arg()), .arg(rev_arg());
) let discard_command = SubCommand::with_name("discard")
.subcommand(
SubCommand::with_name("discard")
.about("discard a commit (and its descendants)") .about("discard a commit (and its descendants)")
.arg(rev_arg()), .arg(rev_arg());
) let restore_command = SubCommand::with_name("restore")
.subcommand(
SubCommand::with_name("restore")
.about("restore paths from another revision") .about("restore paths from another revision")
.arg( .arg(
Arg::with_name("source") Arg::with_name("source")
@ -400,39 +357,23 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.default_value("@"), .default_value("@"),
) )
.arg( .arg(Arg::with_name("interactive").long("interactive").short("i"))
Arg::with_name("interactive") .arg(Arg::with_name("paths").index(1).multiple(true));
.long("interactive") let edit_command = SubCommand::with_name("edit")
.short("i"),
)
.arg(
Arg::with_name("paths")
.index(1)
.multiple(true),
),
)
.subcommand(
SubCommand::with_name("edit")
.about("edit the content changes in a revision") .about("edit the content changes in a revision")
.arg(rev_arg()), .arg(rev_arg());
) let split_command = SubCommand::with_name("split")
.subcommand(
SubCommand::with_name("split")
.about("split a revision in two") .about("split a revision in two")
.arg(rev_arg()), .arg(rev_arg());
) let merge_command = SubCommand::with_name("merge")
.subcommand(
SubCommand::with_name("merge")
.about("merge work from multiple branches") .about("merge work from multiple branches")
.arg( .arg(
Arg::with_name("revisions") Arg::with_name("revisions")
.index(1) .index(1)
.required(true) .required(true)
.multiple(true), .multiple(true),
), );
) let rebase_command = SubCommand::with_name("rebase")
.subcommand(
SubCommand::with_name("rebase")
.about("move a commit to a different parent") .about("move a commit to a different parent")
.arg(rev_arg()) .arg(rev_arg())
.arg( .arg(
@ -442,10 +383,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.multiple(true), .multiple(true),
), );
) let backout_command = SubCommand::with_name("backout")
.subcommand(
SubCommand::with_name("backout")
.about("apply the reverse of a commit on top of another commit") .about("apply the reverse of a commit on top of another commit")
.arg(rev_arg()) .arg(rev_arg())
.arg( .arg(
@ -455,13 +394,10 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.default_value("@") .default_value("@")
.multiple(true), .multiple(true),
), );
) let evolve_command =
.subcommand( SubCommand::with_name("evolve").about("resolve problems with the repo's meta-history");
SubCommand::with_name("evolve").about("resolve problems with the repo's meta-history"), let operation_command = SubCommand::with_name("operation")
)
.subcommand(
SubCommand::with_name("operation")
.alias("op") .alias("op")
.about("commands for working with the operation log") .about("commands for working with the operation log")
.subcommand(SubCommand::with_name("log").about("show the operation log")) .subcommand(SubCommand::with_name("log").about("show the operation log"))
@ -474,10 +410,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("restore") SubCommand::with_name("restore")
.about("restore to the state at an operation") .about("restore to the state at an operation")
.arg(op_arg()), .arg(op_arg()),
), );
) let bench_command = SubCommand::with_name("bench")
.subcommand(
SubCommand::with_name("bench")
.about("commands for benchmarking internal operations") .about("commands for benchmarking internal operations")
.subcommand( .subcommand(
SubCommand::with_name("commonancestors") SubCommand::with_name("commonancestors")
@ -501,10 +435,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
SubCommand::with_name("resolveprefix") SubCommand::with_name("resolveprefix")
.about("resolve a commit id prefix") .about("resolve a commit id prefix")
.arg(Arg::with_name("prefix").index(1).required(true)), .arg(Arg::with_name("prefix").index(1).required(true)),
), );
) let debug_command = SubCommand::with_name("debug")
.subcommand(
SubCommand::with_name("debug")
.about("low-level commands not intended for users") .about("low-level commands not intended for users")
.subcommand( .subcommand(
SubCommand::with_name("resolverev") SubCommand::with_name("resolverev")
@ -525,8 +457,50 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
.arg(Arg::with_name("template").index(1).required(true)), .arg(Arg::with_name("template").index(1).required(true)),
) )
.subcommand(SubCommand::with_name("index").about("show commit index stats")) .subcommand(SubCommand::with_name("index").about("show commit index stats"))
.subcommand(SubCommand::with_name("reindex").about("rebuild commit index")), .subcommand(SubCommand::with_name("reindex").about("rebuild commit index"));
App::new("Jujube")
.global_setting(clap::AppSettings::ColoredHelp)
.version("0.0.1")
.author("Martin von Zweigbergk <martinvonz@google.com>")
.about("My source control tool")
.arg(
Arg::with_name("repository")
.long("repository")
.short("R")
.takes_value(true)
.default_value("."),
) )
.arg(
Arg::with_name("at_op")
.long("at-operation")
.alias("at-op")
.takes_value(true),
)
.subcommand(init_command)
.subcommand(checkout_command)
.subcommand(files_command)
.subcommand(diff_command)
.subcommand(status_command)
.subcommand(log_command)
.subcommand(obslog_command)
.subcommand(describe_command)
.subcommand(close_command)
.subcommand(open_command)
.subcommand(duplicate_command)
.subcommand(prune_command)
.subcommand(new_command)
.subcommand(squash_command)
.subcommand(discard_command)
.subcommand(restore_command)
.subcommand(edit_command)
.subcommand(split_command)
.subcommand(merge_command)
.subcommand(rebase_command)
.subcommand(backout_command)
.subcommand(evolve_command)
.subcommand(operation_command)
.subcommand(bench_command)
.subcommand(debug_command)
} }
fn cmd_init( fn cmd_init(