apple / swift-argument-parser

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

USAGE command name should always reflect the actual binary name #295

Open eaigner opened 3 years ago

eaigner commented 3 years ago

The default USAGE output derives the usage command name from the ParsableCommand type name. Now this might be correct or not. The "correct" way would be to always use the last path component of argv[0], as it would also show the correct string in case the build product name is different from the class name or the user renames the tool.

While there is _commandName I can use to override this, it is marked as for internal use only.

frou commented 3 years ago

Another common occurrence of this is running the executable via a symlink, where the symlink has a different basename to the executable it's pointing to.

I guess ProcessInfo.processInfo.processName from Foundation already has the logic for slicing up argv[0]?