Class: Command::CommandBase
- Inherits:
-
Object
- Object
- Command::CommandBase
- Defined in:
- lib/commandbase.rb
Direct Known Subclasses
Alias, Browser, Convert, Diff, Download, Folder, Freeze, Help, Init, Inspect, List, Remove, Send, Setting, Update, Version
Class Method Summary collapse
-
.execute_and_rescue_exit(argv) ⇒ Object
普通にコマンドを実行するけど、exit(2) を補足してexitstatus を返す 正常終了なら0.
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#initialize(postfix = "") ⇒ CommandBase
constructor
A new instance of CommandBase.
- #oneline_help(msg) ⇒ Object
Constructor Details
#initialize(postfix = "") ⇒ CommandBase
Returns a new instance of CommandBase.
10 11 12 13 14 15 16 |
# File 'lib/commandbase.rb', line 10 def initialize(postfix = "") @opt = OptionParser.new(nil, 20) @opt. = ("<bold><green>" + TermColor.escape("Usage: narou #{self.class.to_s.scan(/::(.+)$/)[0][0].downcase} #{postfix}") + "</green></bold>").termcolor @options = {} end |
Class Method Details
.execute_and_rescue_exit(argv) ⇒ Object
普通にコマンドを実行するけど、exit(2) を補足してexitstatus を返す 正常終了なら0
32 33 34 35 36 37 38 |
# File 'lib/commandbase.rb', line 32 def self.execute_and_rescue_exit(argv) self.new.execute(argv) rescue SystemExit => e e.status else 0 end |
Instance Method Details
#execute(argv) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/commandbase.rb', line 18 def execute(argv) @opt.parse!(argv) rescue OptionParser::InvalidOption => e error "不正なオプションです(#{e})" exit 1 rescue OptionParser::MissingArgument => e error "オプションの引数が不正です(#{e})" exit 1 end |
#oneline_help(msg) ⇒ Object
40 41 42 |
# File 'lib/commandbase.rb', line 40 def oneline_help(msg) "" end |