Open MaxDesiatov opened 5 months ago
Sorry you ran into this, @MaxDesiatov! There's a default implementation of the run()
method for all parsable commands, since for intermediate commands in a command hierarchy, there's generally nothing to do other than printing the help screen. I'm reticent to add a warning to the output of a validly-built ParsableCommand
type, even in debug mode, since I'm not sure of all the contexts where these commands run. Do you have any other suggestions about how we could surface this potential issue?
When passing any arguments like server foo bar, no output is produced whatsoever.
This sounds like a different issue – if you're able to create a reproducing command, could you file this separately? For the command above, I get this output:
$ entrypoint server foo bar
Error: 2 unexpected arguments: 'foo', 'bar'
Usage: entrypoint server
See 'entrypoint server --help' for more information.
When accidentally defining
main
instead ofrun
in subcommands, no warning or error is shown, but the subcommand itself either displays a help message or swallows all arguments with no output.ArgumentParser version:
1.2.0
and1.3.0
or themain
branch, for example. Swift version: Apple Swift version 6.0-dev (LLVM ce41a43bba95b2b, Swift 1a840948a0905df), also reproducible with Swift 5.10.0 from Xcode 15.3.0Checklist
main
branch of this packageSteps to Reproduce
Build and run an executable that has only this code:
Expected behavior
I realize that I should've defined
run
instead of main, but definingmain
inEntrypoint
does work, that function is called, albeit with no argument parsing done IIUC. The actual behavior for subcommands is unexpected. The default implementation ofParsableCommand
andAsyncParsableCommand
should at least issue a warning, if possible, that no custom implementaiton ofrun
is provided. Otherwise it's very easy to spend a long time debugging this issue.I'd assume this can also be a very frustrating experience for first-time users who try to convert their existing
@main
entrypoint toParsableCommand
but don't realize they have to renamestatic func main()
tofunc run()
.Actual behavior
When running
server
orclient
subcommands on their own, a help message is shown, but not other output is produced:When passing any arguments like
server foo bar
, no output is produced whatsoever.