Class: QueryStream::Command::Top
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- QueryStream::Command::Top
- Defined in:
- lib/query_stream/command.rb
Overview
トップレベルコマンド
Instance Method Summary collapse
-
#call ⇒ Object
コマンド実行.
-
#print_usage(output: $stdout) ⇒ Object
使い方を表示する。.
Instance Method Details
#call ⇒ Object
コマンド実行
24 25 26 27 28 29 30 |
# File 'lib/query_stream/command.rb', line 24 def call if @options[:version] puts "query-stream #{QueryStream::VERSION}" else print_usage end end |
#print_usage(output: $stdout) ⇒ Object
使い方を表示する。
public かつ output: を受ける形でなければならない。Samovar は引数の解析に
失敗すると、外から error.command.print_usage(output: output) を呼んで
使い方を出そうとする。private に置いていた頃は、そこで
private method 'print_usage' called の NoMethodError になり、
--help と未知の引数がスタックトレースで落ちていた。
40 41 42 43 44 45 |
# File 'lib/query_stream/command.rb', line 40 def print_usage(output: $stdout) output.puts self.class.description output.puts 'Usage: query-stream [options]' output.puts ' --version Print version and exit' output.puts ' --help Print this message and exit' end |