commit ad2839962a7ffd0d7c257f25db8ad42c141a2864
parent 7c806bc7a394e10c901e14a049dd3713ea2d3fe8
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 13 Aug 2021 09:56:14 +0100
correct usage message for invoking an alias
Diffstat:
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/features/moss.feature b/features/moss.feature
@@ -118,4 +118,7 @@ Feature: command-line password management
Scenario: argument checking
When I run "moss show"
- Then it complains that the wrong arguments were given
+ Then it shows a usage message for "show"
+
+ When I run "moss cat"
+ Then it shows a usage message for "cat"
diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb
@@ -197,7 +197,7 @@ When("I run {string}") do |command|
@exit_status = $?.exitstatus
end
-Then("it complains that the wrong arguments were given") do
+Then("it shows a usage message for {string}") do |command|
expect(@exit_status).to be > 0
- expect(@i_see).to match /usage: moss show \<file\>/
+ expect(@i_see).to match /usage: moss #{command} \<file\>/
end
diff --git a/moss.rb b/moss.rb
@@ -235,7 +235,7 @@ class CLI
public_send(name, *payload)
end
rescue ArgumentError => e
- raise UsageError, "usage: moss #{describe_usage(name)}"
+ raise UsageError, "usage: moss #{argv.first} #{params_to_s(method(name))}"
end
end