Class: TimeTally::Shell
- Inherits:
-
Object
- Object
- TimeTally::Shell
- Defined in:
- lib/time_tally/shell.rb
Constant Summary collapse
- BANNER =
<<~"MSG".freeze usage: #{$PROGRAM_NAME} Takes copied data from the report screen of toggle and formats a total amount of time per task MSG
Class Method Summary collapse
-
.gather_options(argv) ⇒ Object
rubocop:disable Metrics/MethodLength.
- .run(argv, out: $stdout, err: $stderr) {|options| ... } ⇒ Object
- .usage(err: $stderr) ⇒ Object
Class Method Details
.gather_options(argv) ⇒ Object
rubocop:disable Metrics/MethodLength
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/time_tally/shell.rb', line 26 def self.(argv) # rubocop:disable Metrics/MethodLength = { show_version: false } OptionParser.new { |parser| parser. = BANNER parser.on("-v", "--version", "Show version") do |version| [:show_version] = version end parser.on("-h", "--help", "Prints this help") do puts parser exit end }.parse! argv end |
.run(argv, out: $stdout, err: $stderr) {|options| ... } ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/time_tally/shell.rb', line 16 def self.run(argv, out: $stdout, err: $stderr) = (argv) out.puts "version: #{TimeTally::VERSION}" if .delete(:show_version) usage(err: err) unless argv.size == 0 yield() end |
.usage(err: $stderr) ⇒ Object
11 12 13 14 |
# File 'lib/time_tally/shell.rb', line 11 def self.usage(err: $stderr) err.puts BANNER exit 1 end |