Class: Vishnu::StandardTime::CLI
- Inherits:
-
Object
- Object
- Vishnu::StandardTime::CLI
- Defined in:
- lib/vishnu/standard_time/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, out, err) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, out, err) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 |
# File 'lib/vishnu/standard_time/cli.rb', line 14 def initialize(argv, out, err) @argv = argv.dup @out = out @err = err end |
Class Method Details
.call(argv = ARGV, out = $stdout, err = $stderr) ⇒ Object
9 10 11 12 |
# File 'lib/vishnu/standard_time/cli.rb', line 9 def self.call(argv = ARGV, out = $stdout, err = $stderr) status = new(argv, out, err).run status.nil? ? 0 : Integer(status) end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vishnu/standard_time/cli.rb', line 20 def run command = (@argv.shift || "now").to_s case command when "now" now when "percent" percent when "flows-left", "left" flows_left when "stamp" stamp when "convert" convert when "after" after when "until" until_flow when "timer" timer(focus: false) when "focus" timer(focus: true) when "prompt" @out.puts Vishnu::StandardTime.format_prompt(Vishnu::StandardTime.local_now) when "badge" badge when "link", "site" @out.puts Vishnu::StandardTime.standard_link when "help", "-h", "--help" help when "version", "-v", "--version" @out.puts Vishnu::StandardTime::VERSION else @err.puts "Unknown command: #{command}" help(@err) 1 end rescue ArgumentError => e @err.puts "vst: #{e.}" 1 end |