Class: Cureutils::CLI
- Inherits:
-
Thor
- Object
- Thor
- Cureutils::CLI
- Defined in:
- lib/cureutils/cli.rb
Overview
The class represents the cli interface
Class Method Summary collapse
Instance Method Summary collapse
-
#date(fmt = '+%F %H:%M:%S @P') ⇒ Object
Original date command’s default is ‘+%a %b %e %H:%M:%S %Z %Y @P’ However, I would like to adopt this setting.
-
#echo ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#girls ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#grep(default_pat = '[:precure_name:]', filename = nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/LineLength.
- #humanize ⇒ Object
- #janken ⇒ Object
- #precures ⇒ Object
- #tr(pat_from = '[:precure_name:]', pat_to = '[:human_name:]') ⇒ Object
- #transform ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
23 24 25 |
# File 'lib/cureutils/cli.rb', line 23 def exit_on_failure? true end |
Instance Method Details
#date(fmt = '+%F %H:%M:%S @P') ⇒ Object
Original date command’s default is ‘+%a %b %e %H:%M:%S %Z %Y @P’ However, I would like to adopt this setting.
145 146 147 148 149 150 151 |
# File 'lib/cureutils/cli.rb', line 145 def date(fmt = '+%F %H:%M:%S @P') logic = DateLogic.new logic.opt_date([:date]) logic.opt_file([:file]) logic.format = fmt exit(logic.print_results) end |
#echo ⇒ Object
rubocop:disable Metrics/AbcSize
126 127 128 129 130 131 132 133 |
# File 'lib/cureutils/cli.rb', line 126 def echo # rubocop:disable Metrics/AbcSize logic = EchoLogic.new logic.precure([:precure]) logic.msg_attack([:attack]) logic.nosleep([:quick]) logic.style([:style]) exit(logic.print_results) end |
#girls ⇒ Object
rubocop:disable Metrics/MethodLength
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cureutils/cli.rb', line 57 def girls # rubocop:disable Metrics/MethodLength girls = Precure.all_girls girls.delete(Cure.echo) unless [:movie] if ['full-name'.to_sym] girls.each do |v| puts v.full_name end else girls.each do |v| puts v.human_name end end end |
#grep(default_pat = '[:precure_name:]', filename = nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/LineLength
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cureutils/cli.rb', line 91 def grep(default_pat = '[:precure_name:]', filename = nil) # rubocop:disable Metrics/AbcSize, Metrics/LineLength logic = GrepLogic.new logic.source_input(filename) logic.pattern(default_pat.clone, ['extended-regexp'.to_sym]) # Check the file discriptor to check the pipe exists or not. logic.option_colorize($stdout.isatty) logic.option_only(['only-matching'.to_sym]) # Print matched lines. exit(logic.print_results) end |
#humanize ⇒ Object
42 43 44 45 46 47 |
# File 'lib/cureutils/cli.rb', line 42 def humanize logic = TranslateLogic.new logic.translate_from_to('[:precure_name:]', '[:human_name:]') logic.in = $stdin exit(logic.print_results) end |
#janken ⇒ Object
154 155 156 157 |
# File 'lib/cureutils/cli.rb', line 154 def janken logic = JankenLogic.new exit(logic.janken.to_i) end |
#precures ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/cureutils/cli.rb', line 75 def precures cures = Precure.all_girls cures.delete(Cure.echo) unless [:movie] cures.map!(&:precure_name) cures.each do |v| puts v end end |
#tr(pat_from = '[:precure_name:]', pat_to = '[:human_name:]') ⇒ Object
103 104 105 106 107 108 |
# File 'lib/cureutils/cli.rb', line 103 def tr(pat_from = '[:precure_name:]', pat_to = '[:human_name:]') logic = TranslateLogic.new logic.in = $stdin logic.translate_from_to(pat_from, pat_to) exit(logic.print_results) end |
#transform ⇒ Object
34 35 36 37 38 39 |
# File 'lib/cureutils/cli.rb', line 34 def transform logic = TranslateLogic.new logic.translate_from_to('[:human_name:]', '[:precure_name:]') logic.in = $stdin exit(logic.print_results) end |