File tree Expand file tree Collapse file tree 2 files changed +28
-19
lines changed Expand file tree Collapse file tree 2 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,8 @@ def main(args)
85
85
86
86
Stud ::untrap ( "INT" , @startup_interruption_trap )
87
87
88
- if args . empty? then
89
- exit ( 0 )
90
- else
91
- task = run ( args )
92
- exit ( task . wait )
93
- end
88
+ task = run ( args )
89
+ exit ( task . wait )
94
90
end # def self.main
95
91
96
92
def run ( args )
@@ -170,21 +166,20 @@ def run(args)
170
166
$stderr. puts "No such command #{ command . inspect } "
171
167
end
172
168
end
173
- $stderr. puts "Usage: logstash <command> [command args]"
174
- $stderr. puts "Run a command with the --help flag to see the arguments."
175
- $stderr. puts "For example: logstash agent --help"
176
- $stderr. puts
177
- # hardcode the available commands to reduce confusion.
178
- $stderr. puts "Available commands:"
179
- $stderr. puts " agent - runs the logstash agent"
180
- $stderr. puts " version - emits version info about this logstash"
181
- $stderr. puts " web - runs the logstash web ui (called Kibana)"
182
- $stderr. puts " rspec - runs tests"
169
+ $stderr. puts %q[
170
+ Usage: logstash <command> [command args]
171
+ Run a command with the --help flag to see the arguments.
172
+ For example: logstash agent --help
173
+
174
+ Available commands:
175
+ agent - runs the logstash agent
176
+ version - emits version info about this logstash
177
+ web - runs the logstash web ui (called Kibana)
178
+ rspec - runs tests
179
+ ]
183
180
#$stderr.puts commands.keys.map { |s| " #{s}" }.join("\n")
184
- exit 1
181
+ return Stud :: Task . new { 1 }
185
182
end
186
-
187
- return args
188
183
end # def run
189
184
190
185
# @return true if this file is the main file being run and not via rspec
Original file line number Diff line number Diff line change @@ -22,6 +22,20 @@ def run(args); end
22
22
expect ( subject . run ( args ) . wait ) . to eq ( 0 )
23
23
end
24
24
25
+ it "should show help with no arguments" do
26
+ expect ( $stderr) . to receive ( :puts ) . once . and_return ( "No command given" )
27
+ expect ( $stderr) . to receive ( :puts ) . once
28
+ args = [ ]
29
+ expect ( subject . run ( args ) . wait ) . to eq ( 1 )
30
+ end
31
+
32
+ it "should show help for unknown commands" do
33
+ expect ( $stderr) . to receive ( :puts ) . once . and_return ( "No such command welp" )
34
+ expect ( $stderr) . to receive ( :puts ) . once
35
+ args = [ "welp" ]
36
+ expect ( subject . run ( args ) . wait ) . to eq ( 1 )
37
+ end
38
+
25
39
it "should run agent help and not run following commands" do
26
40
expect ( subject ) . to receive ( :show_help ) . once . and_return ( nil )
27
41
args = [ "agent" , "-h" , "web" ]
You can’t perform that action at this time.
0 commit comments