Class: Space2underscore::Cli
- Inherits:
-
Object
- Object
- Space2underscore::Cli
- Defined in:
- lib/space2underscore/cli.rb
Constant Summary collapse
- CREATE_FLAGS =
%w[-c --create].freeze
- RAW_FLAGS =
%w[-r --raw].freeze
- FLAGS =
[CREATE_FLAGS, RAW_FLAGS].flatten.freeze
- ERROR_MSG =
'Option is invalid format. It is only avaliable for `-c --create -d --downcase`'
- OptionParseError =
Class.new(ArgumentError)
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #start ⇒ Object
Constructor Details
Instance Method Details
#start ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/space2underscore/cli.rb', line 21 def start return $stdout.puts Usage.new.content if @argv.empty? if with_all_flags? @executer.run_with_raw(@underscore_include_branch) elsif create_flags_without_raw_flags? @executer.run_with_downcase(@underscore_include_branch) elsif raw_flags_without_create_flags? @printer.run_with_raw(@underscore_include_branch) elsif without_any_flags? @printer.run_with_downcase(@underscore_include_branch) else raise OptionParseError, ERROR_MSG end end |