apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.31k stars 311 forks source link

No output when nothing is passed to command #563

Closed MahdiBM closed 1 year ago

MahdiBM commented 1 year ago

Swiftly (swift-server/swiftly, this revision as of writing this issue) doesn't output anything when nothing is passed to it. This seems very much like an issue of this package, not a fault of Swiftly. Related to https://github.com/swift-server/swiftly/issues/38.

ArgumentParser version: 1.1.2 & the main branch Swift version:

# swift --version
Swift version 5.8 (swift-5.8-RELEASE)
Target: aarch64-unknown-linux-gnu

Checklist

Steps to Reproduce

  1. Clone Swiftly. this revision as of writing this issue.
  2. Run swift run swiftly. There is no output. This is the issue.
    # swift run swiftly
    Building for debugging...
    Build complete! (0.40s)
  3. Run swift run swiftly xxx. Makes you sure the actual command is working:
    # swift run swiftly xxx
    Building for debugging...
    Build complete! (0.44s)
    Error: Unexpected argument 'xxx'
    Usage: swiftly <subcommand>
    See 'swiftly --help' for more information.

Expected behavior

The output of swift run swiftly should be something like the output of swift run swiftly --help. It definitely should not be empty as that might make users think the command is not installed / not working.

Actual behavior

Running swift run swiftly results in no output.

natecook1000 commented 1 year ago

ParsableCommand types provide this behavior (printing help by default) through the default implementation of the run() method. Since the swiftly command provides an empty implementation, that isn't done. You can either remove that implementation or print the result of Swiftly.helpMessage() from within that method.