Skip to content

Commit

Permalink
pyoxidizer: remove unnecessary arg_required_else_help()
Browse files Browse the repository at this point in the history
It looks like there was a subtle change in behavior as a result
of the clap 3.0 and 3.1 upgrade. Before the upgrade, running
sub-commands without arguments would work. Now, it fails by
printing help text.

This commit removes arg_required_else_help() from sub-commands
as this behavior is enforced through required argument handling.

Closes #523.
  • Loading branch information
indygreg committed Mar 15, 2022
1 parent 3de6d7a commit b3825f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 8 additions & 0 deletions pyoxidizer/docs/pyoxidizer_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Version History

Not yet released.

Bug Fixes
^^^^^^^^^

* Fixed regression in the behavior of various ``pyoxidizer`` commands which
prevented them from working without specifying any arguments. This regression
was introduced in 0.20 with the upgrade of the ``clap`` crate to version 3.1.
(#523)

Other Relevant Changes
^^^^^^^^^^^^^^^^^^^^^^

Expand Down
17 changes: 6 additions & 11 deletions pyoxidizer/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ pub fn run_cli() -> Result<()> {
);

let app = app.subcommand(
Command::new("analyze")
.about("Analyze a built binary")
.arg_required_else_help(true)
.arg(Arg::new("path").help("Path to executable to analyze")),
Command::new("analyze").about("Analyze a built binary").arg(
Arg::new("path")
.required(true)
.help("Path to executable to analyze"),
),
);

let app = app.subcommand(add_env_args(
Command::new("build")
.about("Build a PyOxidizer enabled project")
.long_about(BUILD_ABOUT)
.arg_required_else_help(true)
.arg(
Arg::new("target_triple")
.long("target-triple")
Expand Down Expand Up @@ -269,7 +269,6 @@ pub fn run_cli() -> Result<()> {
Command::new("find-resources")
.about("Find resources in a file or directory")
.long_about(RESOURCES_SCAN_ABOUT)
.arg_required_else_help(true)
.arg(
Arg::new("distributions_dir")
.long("distributions-dir")
Expand Down Expand Up @@ -299,7 +298,7 @@ pub fn run_cli() -> Result<()> {
.long("no-emit-files")
.help("Whether to skip emitting File resources"),
)
.arg(Arg::new("path").value_name("PATH").help(
.arg(Arg::new("path").value_name("PATH").required(true).help(
"Filesystem path to scan for resources. Must be a directory or Python wheel",
)),
);
Expand All @@ -318,7 +317,6 @@ pub fn run_cli() -> Result<()> {

let app = app.subcommand(
Command::new("init-config-file")
.arg_required_else_help(true)
.about("Create a new PyOxidizer configuration file.")
.arg(
Arg::new("python-code")
Expand Down Expand Up @@ -347,7 +345,6 @@ pub fn run_cli() -> Result<()> {
Command::new("init-rust-project")
.about("Create a new Rust project embedding a Python interpreter")
.long_about(INIT_RUST_PROJECT_ABOUT)
.arg_required_else_help(true)
.arg(
Arg::new("path")
.required(true)
Expand All @@ -359,7 +356,6 @@ pub fn run_cli() -> Result<()> {
let app = app.subcommand(
Command::new("list-targets")
.about("List targets available to resolve in a configuration file")
.arg_required_else_help(true)
.arg(
Arg::new("path")
.default_value(".")
Expand Down Expand Up @@ -416,7 +412,6 @@ pub fn run_cli() -> Result<()> {
Command::new("run-build-script")
.about("Run functionality that a build script would perform")
.long_about(RUN_BUILD_SCRIPT_ABOUT)
.arg_required_else_help(true)
.arg(
Arg::new("build-script-name")
.required(true)
Expand Down

0 comments on commit b3825f0

Please sign in to comment.