Skip to content

Commit 74f96fd

Browse files
committed
rust: use separate variables for clap
This will avoid code formatting / autocomplete issues when we have many commands.
1 parent 1e32356 commit 74f96fd

File tree

1 file changed

+57
-56
lines changed

1 file changed

+57
-56
lines changed

src/main.rs

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -921,65 +921,66 @@ fn command_validate_distribution(args: &ArgMatches) -> Result<()> {
921921
}
922922

923923
fn main_impl() -> Result<()> {
924-
let matches = App::new("Python Build")
924+
let app = App::new("Python Build")
925925
.setting(AppSettings::ArgRequiredElseHelp)
926926
.version("0.1")
927927
.author("Gregory Szorc <[email protected]>")
928-
.about("Perform tasks related to building Python distributions")
929-
.subcommand(
930-
SubCommand::with_name("fetch-release-distributions")
931-
.about("Fetch builds from GitHub Actions that are release artifacts")
932-
.arg(
933-
Arg::with_name("token")
934-
.long("--token")
935-
.required(true)
936-
.takes_value(true)
937-
.help("GitHub API token"),
938-
)
939-
.arg(
940-
Arg::with_name("commit")
941-
.long("--commit")
942-
.takes_value(true)
943-
.help("Git commit whose artifacts to fetch"),
944-
)
945-
.arg(
946-
Arg::with_name("dest")
947-
.long("dest")
948-
.required(true)
949-
.takes_value(true)
950-
.help("Destination directory"),
951-
)
952-
.arg(
953-
Arg::with_name("organization")
954-
.long("--org")
955-
.takes_value(true)
956-
.default_value("indygreg")
957-
.help("GitHub organization"),
958-
)
959-
.arg(
960-
Arg::with_name("repo")
961-
.long("--repo")
962-
.takes_value(true)
963-
.default_value("python-build-standalone")
964-
.help("GitHub repository name"),
965-
),
966-
)
967-
.subcommand(
968-
SubCommand::with_name("validate-distribution")
969-
.about("Ensure a distribution archive conforms to standards")
970-
.arg(
971-
Arg::with_name("run")
972-
.long("--run")
973-
.help("Run the interpreter to verify behavior"),
974-
)
975-
.arg(
976-
Arg::with_name("path")
977-
.help("Path to tar.zst file to validate")
978-
.multiple(true)
979-
.required(true),
980-
),
981-
)
982-
.get_matches();
928+
.about("Perform tasks related to building Python distributions");
929+
let app = app.subcommand(
930+
SubCommand::with_name("fetch-release-distributions")
931+
.about("Fetch builds from GitHub Actions that are release artifacts")
932+
.arg(
933+
Arg::with_name("token")
934+
.long("--token")
935+
.required(true)
936+
.takes_value(true)
937+
.help("GitHub API token"),
938+
)
939+
.arg(
940+
Arg::with_name("commit")
941+
.long("--commit")
942+
.takes_value(true)
943+
.help("Git commit whose artifacts to fetch"),
944+
)
945+
.arg(
946+
Arg::with_name("dest")
947+
.long("dest")
948+
.required(true)
949+
.takes_value(true)
950+
.help("Destination directory"),
951+
)
952+
.arg(
953+
Arg::with_name("organization")
954+
.long("--org")
955+
.takes_value(true)
956+
.default_value("indygreg")
957+
.help("GitHub organization"),
958+
)
959+
.arg(
960+
Arg::with_name("repo")
961+
.long("--repo")
962+
.takes_value(true)
963+
.default_value("python-build-standalone")
964+
.help("GitHub repository name"),
965+
),
966+
);
967+
let app = app.subcommand(
968+
SubCommand::with_name("validate-distribution")
969+
.about("Ensure a distribution archive conforms to standards")
970+
.arg(
971+
Arg::with_name("run")
972+
.long("--run")
973+
.help("Run the interpreter to verify behavior"),
974+
)
975+
.arg(
976+
Arg::with_name("path")
977+
.help("Path to tar.zst file to validate")
978+
.multiple(true)
979+
.required(true),
980+
),
981+
);
982+
983+
let matches = app.get_matches();
983984

984985
match matches.subcommand() {
985986
("fetch-release-distributions", Some(args)) => {

0 commit comments

Comments
 (0)