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)
8585
8686 Stud ::untrap ( "INT" , @startup_interruption_trap )
8787
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 )
9490 end # def self.main
9591
9692 def run ( args )
@@ -170,21 +166,20 @@ def run(args)
170166 $stderr. puts "No such command #{ command . inspect } "
171167 end
172168 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+ ]
183180 #$stderr.puts commands.keys.map { |s| " #{s}" }.join("\n")
184- exit 1
181+ return Stud :: Task . new { 1 }
185182 end
186-
187- return args
188183 end # def run
189184
190185 # @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
2222 expect ( subject . run ( args ) . wait ) . to eq ( 0 )
2323 end
2424
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+
2539 it "should run agent help and not run following commands" do
2640 expect ( subject ) . to receive ( :show_help ) . once . and_return ( nil )
2741 args = [ "agent" , "-h" , "web" ]
You can’t perform that action at this time.
0 commit comments