Class: TogglCmd::RunnerOptions
- Inherits:
-
Hash
- Object
- Hash
- TogglCmd::RunnerOptions
- Defined in:
- lib/toggl_cmd/runner_options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(args) ⇒ RunnerOptions
constructor
A new instance of RunnerOptions.
Constructor Details
#initialize(args) ⇒ RunnerOptions
Returns a new instance of RunnerOptions.
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 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 61 62 63 64 65 66 67 68 |
# File 'lib/toggl_cmd/runner_options.rb', line 6 def initialize(args) super() @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options]" o.on('-D', '--dump', 'Dumps data for each user in ~/.toggl_team to a table in CRM.') do |dump| self[:dump] = dump end o.on('-S', '--since DATE', 'The date (inclusive) to start dumping tasks from with the --dump option.') do |since| self[:since] = since end o.on('-T', '--through DATE', 'The date (inclusive) to stop dumping tasks from with the --dump option.') do |through| self[:through] = through end o.on('-t', '--title TITLE', 'What do you want to register?') do |title| self[:description] = title end o.on('-p', '--project PROJECT', 'Who is going to pay?') do |project| self[:project] = project end o.on('-s', '--duration DURATION', 'How long did it take?') do |duration| self[:duration] = duration end o.on('-d', '--date DATE', 'When exactly did it happen?') do |date| self[:start] = date end o.on('--tasks', 'Show tasks') do |tasks| self[:tasks] = tasks end o.on('--projects', 'Show projects') do |projects| self[:projects] = projects end o.on('--delete TASK_ID', 'Delete tasks with id') do |task_id| self[:delete] = task_id end o.on('-v', '--verbose', 'What\'s happening?') do |debug| self[:debug] = debug end o.on_tail('-h', '--help', 'Display this help and exit') do puts @opts exit end end begin @opts.parse!(args) rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. end end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/toggl_cmd/runner_options.rb', line 4 def opts @opts end |