Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running command with overloaded run function with all params having default values prints help instead of running command #670

Open
2 tasks done
rgoldberg opened this issue Sep 26, 2024 · 0 comments

Comments

@rgoldberg
Copy link
Contributor

If a run function is defined with parameters, each of which has a default value (e.g., func run(arg: Type = defaultValue)), the function can be called via run().

Each ParsableCommand has a default run() function that outputs its help info, however, so that gets called instead of the overload with its default values.

If run() isn't specifically overridden in a subtype of ParsableCommand, but it is overloaded by another function that has default values for each of its parameters, can you autogenerate a run() that calls the defaulted overload?

This is similar to other open issues (#622 & #538), all of which stem from the default implementation of run() in ParsableCommand (see #622 (comment)).

ArgumentParser version:
1.5.0

Swift version:
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: x86_64-apple-macosx12.0

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

@main
struct Command: ParsableCommand {
    func run(param: String = "default") {
        print("Ran defaulted overload")
    }
}

Expected behavior

Prints "Ran defaulted overload"

Actual behavior

Prints help info for command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant