From 40dcefff0beda3416514184cf1bba53c2f7ae639 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Wed, 9 Mar 2016 18:47:42 -0600 Subject: [PATCH] [ArgumentSuggester] Add a question mark after did you mean --- lib/claide/command/argument_suggester.rb | 4 ++-- spec/command/argument_suggester_spec.rb | 5 +++-- spec/command_spec.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/claide/command/argument_suggester.rb b/lib/claide/command/argument_suggester.rb index 3fb7ae4..ba6623e 100644 --- a/lib/claide/command/argument_suggester.rb +++ b/lib/claide/command/argument_suggester.rb @@ -45,7 +45,7 @@ def suggestion pretty_suggestion = self.class.prettify_suggestion(suggestion, @argument_type) "Unknown #{argument_description}: `#{@argument}`\n" \ - "Did you mean: #{pretty_suggestion}" + "Did you mean: #{pretty_suggestion}?" else "Unknown #{argument_description}: `#{@argument}`" end @@ -64,7 +64,7 @@ def suggestion def self.prettify_suggestion(suggestion, argument_type) case argument_type when :option, :flag - suggestion = "#{suggestion}" + suggestion = suggestion.to_s suggestion.ansi.blue when :arg suggestion.ansi.green diff --git a/spec/command/argument_suggester_spec.rb b/spec/command/argument_suggester_spec.rb index 4bb466b..17032cd 100644 --- a/spec/command/argument_suggester_spec.rb +++ b/spec/command/argument_suggester_spec.rb @@ -32,7 +32,8 @@ class CLAide::Command describe '#suggestion' do it 'returns the message for a command' do result = ArgumentSuggester.new('spec_file', Fixture::Command).suggestion - result.should == "Unknown command: `spec_file`\nDid you mean: spec-file" + result. + should == "Unknown command: `spec_file`\nDid you mean: spec-file?" end it 'returns the message for when no suggestion is possible' do @@ -43,7 +44,7 @@ class CLAide::Command it 'returns the message for an option' do result = ArgumentSuggester.new('--verbosa', Fixture::Command).suggestion - result.should == "Unknown option: `--verbosa`\nDid you mean: --verbose" + result.should == "Unknown option: `--verbosa`\nDid you mean: --verbose?" end end end diff --git a/spec/command_spec.rb b/spec/command_spec.rb index 16350d1..ffc3bdb 100644 --- a/spec/command_spec.rb +++ b/spec/command_spec.rb @@ -153,12 +153,12 @@ module CLAide end it 'raises a Help exception when created with an invalid subcommand' do - message = "Unknown command: `unknown`\nDid you mean: spec-file" + message = "Unknown command: `unknown`\nDid you mean: spec-file?" should_raise_help message do @command.parse(%w(unknown)).validate! end - should_raise_help "Unknown command: `unknown`\nDid you mean: lint" do + should_raise_help "Unknown command: `unknown`\nDid you mean: lint?" do @command.parse(%w(spec-file unknown)).validate! end end