Class: Alvalaxia::Runner
- Inherits:
-
Object
- Object
- Alvalaxia::Runner
- Defined in:
- lib/alvalaxia/runner.rb
Constant Summary collapse
- CONFIG_FILE =
File.('~/.alvalaxiarc')
Instance Method Summary collapse
-
#generate_commands ⇒ Object
create all the cli options.
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
-
#start ⇒ Object
start the cli args parsing.
Constructor Details
Instance Method Details
#generate_commands ⇒ Object
create all the cli options
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 |
# File 'lib/alvalaxia/runner.rb', line 25 def generate_commands # creating the setup command setup = CmdParse::Command.new('setup', false) setup.short_desc = 'Creates the config file needed to place the events in a google calendar.' setup.description = 'This command creates the ~/.alvalaxiarc file with empty credentials. ' setup.description << 'User needs to fill in the google calendar credentials.' setup.set_execution_block do if has_config_file? puts 'The config file already exists. If you need to change it, edit it ( ~/.alvalaxiarc )' else create_config_file puts 'Config file created at ~/.alvalaxiarc, edit it with your credentials.' end end # creating the run command run = CmdParse::Command.new('run', false) run.short_desc = 'Runs the program.' run.description = 'Gets the SCP home games and places them as events on a given google calendar.' run.set_execution_block do if has_config_file? main else puts 'You first need to run the "setup" option to generate a config file.' end end @cmd.add_command(setup) @cmd.add_command(run) @cmd.add_command(CmdParse::HelpCommand.new, true) @cmd.add_command(CmdParse::VersionCommand.new, false) end |
#start ⇒ Object
start the cli args parsing
20 21 22 |
# File 'lib/alvalaxia/runner.rb', line 20 def start @cmd.parse end |