Class: Menu::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/menu/generator.rb

Overview

Menu generator

Class Method Summary collapse

Class Method Details

.make_config_menuSlop::Result

Creates the config menu.

Returns:

  • (Slop::Result)

    A Slop::Result instance.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/menu/generator.rb', line 45

def self.make_config_menu
  opts = Slop::Options.new
  opts.banner = "usage: #{$PROGRAM_NAME} config [option] [value]"
  opts.string "url", "Set the JIRA Server URL."
  opts.string "shift_start", "Set shift start time. Format: HH:mm, e.g. '10:00'."
  opts.string "shift_end", "Set shift end time. Format: HH:mm, e.g. '18:00'."
  opts.bool "list", "Lists all configuration values."

  Slop::Parser.new(opts).parse(ARGV[1..ARGV.count - 1])
rescue Slop::MissingArgument => e
  puts e
  exit 1
end

.make_main_menuSlop::Result

Creates the main menu.

Returns:

  • (Slop::Result)

    A Slop::Result instance.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/menu/generator.rb', line 28

def self.make_main_menu
  Slop.parse(ARGV[0..1]) do |o|
    o.bool "setup", "Run the initial setup wizard."
    o.bool "login", "Login with your JIRA credentials."
    o.bool "logout", "Logout current user."
    o.bool "config", "Update configuration."
    o.bool "scheduled", "Manage scheduled issues."
    o.on "--version", "-v", "Prints jira-logwork version." do
      puts "jira-logwork v#{Constants::VERSION}"
      exit
    end
  end
end

.make_scheduled_menuSlop::Result

Creates the repeatables menu.

Returns:

  • (Slop::Result)

    A Slop::Result instance.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/menu/generator.rb', line 62

def self.make_scheduled_menu
  opts = Slop::Options.new
  opts.banner = "usage: scheduled [command] [ISSUE_ID] [options]"
  opts.string "add", "Add a new scheduled issue. Syntax: 'add [ISSUE_ID] [Options]', e.g. add ABC-13 10:00 2h30m."
  opts.string "remove", "Remove a scheduled issue from Database. Syntax 'remove [ISSUE_ID]', e.g. remove ABC-13. You can specify the --date option to remove from a specific date."
  opts.bool "list", "List scheduled issues."
  opts.separator "Options:"
  opts.string "--repeat", "An integer that indicates the day of the week the issue is repeated: 0: Everyday, 1: Monday - 7: Sunday."
  opts.string "--date", "A date the issue will be scheduled in MM/DD/YYYY format."
  opts.string "--start_time", "Time in 24h format (optional), e.g. 10:00. "
  opts.string "--duration", "A duration of the issue (optional), e.g. 30m, 1h30m, etc."
  Slop::Parser.new(opts).parse(ARGV[1..ARGV.count - 1])
rescue Slop::MissingArgument => e
  puts e
  exit 1
end