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

[SR-785] Command line argument parsing: swift-test should print help when passed -h, --help #5318

Closed
modocache mannequin opened this issue Feb 21, 2016 · 6 comments
Closed
Assignees

Comments

@modocache
Copy link
Mannequin

modocache mannequin commented Feb 21, 2016

Previous ID SR-785
Radar None
Original Reporter @modocache
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Improvement, StarterBug
Assignee @aciidb0mb3r
Priority Medium

md5: 3add60f1bf6a3cfdae084373421fe1a7

Issue Description:

swift-build prints instructions on how to use it when passed --help:

$ swift-build --help
OVERVIEW: Build sources into binary products

USAGE: swift build [options]

MODES:
  --configuration <value>  Build with configuration (debug|release) [-c]
  --clean[=<mode>]         Delete artefacts (build|dist) [-k]
  --init                   Creates a new Swift project
  --fetch                  Fetch package dependencies

OPTIONS:
  --chdir <value>    Change working directory before any other operation [-C]
  -v[v]              Increase verbosity of informational output
  -Xcc <flag>        Pass flag through to all C compiler instantiations
  -Xlinker <flag>    Pass flag through to all linker instantiations
  -Xswiftc <flag>    Pass flag through to all Swift compiler instantiations

swift-test does not do the same:

$ swift-test --help
error: system(["swift-build-tool", "-f", "/Users/bgesiak/GitHub/tmp/SimpleGetClient/.build/debug.yaml", "test"], posix_spawn error: No such file or directory (2), `["swift-build-tool", "-f", "/Users/bgesiak/GitHub/tmp/SimpleGetClient/.build/debug.yaml", "test"]`)

The underlying problem is that the command-line parsing for swift-build is not shared with swift-test. It seems like we should share a generic command line argument parsing mechanism.

I know a great deal of command line argument parsing modules exist on GitHub. https://github.com/kylef/Commander in particular is installable via SwiftPM. Perhaps we should consider using an existing solution?

@stephencelis
Copy link
Contributor

I also wonder if there's a reason why `swift-build` takes `--help` but not `-h`?

@mxcl
Copy link
Contributor

mxcl commented Feb 22, 2016

SwiftPM cannot depend on external modules due to:

1) Apple Legal review is required, which takes months
2) We need to be able to bootstrap

@mxcl
Copy link
Contributor

mxcl commented Feb 22, 2016

Added `-h`

@modocache
Copy link
Mannequin Author

modocache mannequin commented Feb 23, 2016

Makes sense! Sounds like the best way forward here is to work to have swift-build and swift-test share a common, internal argument parser. Does that sound right?

@mxcl
Copy link
Contributor

mxcl commented Feb 23, 2016

For this I'd like to see a new module Usage. However I really like the precision of our current model where we use enums to represent the possibilities. I feel it makes the most of Swift. I'm sure a portion can be extracted out still.

@aciidgh
Copy link
Member

aciidgh commented Mar 3, 2016

Should be fixed by #168

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
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

3 participants