picky 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/picky/cli.rb +6 -4
- data/spec/lib/cli_spec.rb +6 -6
- metadata +2 -2
data/lib/picky/cli.rb
CHANGED
@@ -21,8 +21,10 @@ module Picky
|
|
21
21
|
def usage name, params
|
22
22
|
puts "Usage\n picky #{name} #{params_to_s(params)}"
|
23
23
|
end
|
24
|
+
# String params are optional, Symbol params aren't.
|
25
|
+
#
|
24
26
|
def params_to_s params
|
25
|
-
params.map { |param| "
|
27
|
+
params.map { |param| param.respond_to?(:to_str) ? "[#{param}]" : param }.join(' ') if params
|
26
28
|
end
|
27
29
|
end
|
28
30
|
class Statistics < Base
|
@@ -88,10 +90,10 @@ module Picky
|
|
88
90
|
# Maps commands to the other gem's command.
|
89
91
|
#
|
90
92
|
@@mapping = {
|
91
|
-
:generate => [Generate, 'sinatra_client | unicorn_server | empty_unicorn_server', 'app_directory_name
|
93
|
+
:generate => [Generate, :'(sinatra_client | unicorn_server | empty_unicorn_server)', :'app_directory_name'],
|
92
94
|
:help => [Help],
|
93
|
-
:stats => [Statistics, 'logfile
|
94
|
-
:live => [Live, 'host:port/path (
|
95
|
+
:stats => [Statistics, :'logfile (e.g. log/search.log)', 'port (default: 4567)'],
|
96
|
+
:live => [Live, 'host:port/path (default: localhost:8080/admin)', 'port (default: 4568)']
|
95
97
|
}
|
96
98
|
def self.mapping
|
97
99
|
@@mapping
|
data/spec/lib/cli_spec.rb
CHANGED
@@ -19,16 +19,16 @@ describe Picky::CLI do
|
|
19
19
|
@cli.executor_class_for.should == [Picky::CLI::Help]
|
20
20
|
end
|
21
21
|
it 'returns Generator for generate' do
|
22
|
-
@cli.executor_class_for(:generate).should == [Picky::CLI::Generate, "sinatra_client | unicorn_server | empty_unicorn_server", "app_directory_name
|
22
|
+
@cli.executor_class_for(:generate).should == [Picky::CLI::Generate, :"(sinatra_client | unicorn_server | empty_unicorn_server)", :"app_directory_name"]
|
23
23
|
end
|
24
24
|
it 'returns Help for help' do
|
25
25
|
@cli.executor_class_for(:help).should == [Picky::CLI::Help]
|
26
26
|
end
|
27
27
|
it 'returns Statistics for stats' do
|
28
|
-
@cli.executor_class_for(:stats).should == [Picky::CLI::Statistics, "logfile
|
28
|
+
@cli.executor_class_for(:stats).should == [Picky::CLI::Statistics, :"logfile (e.g. log/search.log)", "port (default: 4567)"]
|
29
29
|
end
|
30
30
|
it 'returns Live for live' do
|
31
|
-
@cli.executor_class_for(:live).should == [Picky::CLI::Live, "host:port/path (
|
31
|
+
@cli.executor_class_for(:live).should == [Picky::CLI::Live, "host:port/path (default: localhost:8080/admin)", "port (default: 4568)"]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -45,14 +45,14 @@ describe Picky::CLI do
|
|
45
45
|
end
|
46
46
|
describe 'usage' do
|
47
47
|
it 'calls puts with an usage' do
|
48
|
-
@executor.should_receive(:puts).once.with "Usage\n picky some_name
|
48
|
+
@executor.should_receive(:puts).once.with "Usage\n picky some_name param1 [param2]"
|
49
49
|
|
50
|
-
@executor.usage :some_name, [:param1, '
|
50
|
+
@executor.usage :some_name, [:param1, 'param2']
|
51
51
|
end
|
52
52
|
end
|
53
53
|
describe 'params_to_s' do
|
54
54
|
it 'returns the right string' do
|
55
|
-
@executor.params_to_s([:param1, '
|
55
|
+
@executor.params_to_s([:param1, 'param2']).should == 'param1 [param2]'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|