-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restores the behavior where `--help` would always skip the command to be invoked, while still allowing to pass the `--help` to external subcommands: The following commands print the help message and exit: - `shards --help` - `shards --local --help` - `shards update --help` While the following tries to call `shards-unknown --help` then falls back to print the help message and exit: - `shards unknown --help` Relies on a fixed list of the builtin command names to avoid having each `when` case starting with `display_help_and_exit(opts) if display_help`.
- Loading branch information
1 parent
74fb685
commit b72eacf
Showing
2 changed files
with
92 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "./spec_helper" | ||
|
||
describe "--help" do | ||
it "prints help and doesn't invoke the command" do | ||
metadata = { | ||
version: "1.0.0", | ||
dependencies: { | ||
mock: {git: git_path("mock")}, | ||
}, | ||
} | ||
|
||
[ | ||
"shards --help", | ||
"shards --local --help", | ||
"shards update --help", | ||
].each do |command| | ||
with_shard(metadata) do | ||
output = run command | ||
|
||
# it printed the help message | ||
output.should contain("Commands:") | ||
output.should contain("General options:") | ||
|
||
# it didn't run the command (or default command) | ||
output.should_not contain("Resolving dependencies") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters