Class: GetProcessStartTime::CLI
- Inherits:
-
Object
- Object
- GetProcessStartTime::CLI
- Defined in:
- lib/get_process_start_time/cli.rb
Instance Method Summary collapse
Instance Method Details
#parse_options(argv = ARGV) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/get_process_start_time/cli.rb', line 6 def (argv = ARGV) op = OptionParser.new self.class.module_eval do define_method(:usage) do |msg = nil| puts op.to_s puts "error: #{msg}" if msg exit 1 end end opts = {} op. += ' PID' begin args = op.parse(argv) rescue OptionParser::InvalidOption => e usage e. end if args.size < 1 usage 'PID argument is required' end [opts, args] end |
#run ⇒ Object
32 33 34 35 36 |
# File 'lib/get_process_start_time/cli.rb', line 32 def run opts, args = pid = args.first.to_i puts GetProcessStartTime.start_time(pid).to_f end |