Class: LambdaWhenever::CLI
- Inherits:
-
Object
- Object
- LambdaWhenever::CLI
- Defined in:
- lib/lambda_whenever/cli.rb
Overview
The CLI class handles command-line interface interactions for the Lambda Whenever tool.
Constant Summary collapse
- SUCCESS_EXIT_CODE =
0
- ERROR_EXIT_CODE =
1
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
Instance Method Summary collapse
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/lambda_whenever/cli.rb', line 9 def args @args end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
9 10 11 |
# File 'lib/lambda_whenever/cli.rb', line 9 def option @option end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/lambda_whenever/cli.rb', line 16 def run case option.mode when Option::DRYRUN_MODE option.validate! print_tasks Logger.instance.("Above is your schedule file converted to scheduled tasks; your scheduled tasks was not updated.") Logger.instance.("Run `lambda_whenever --help' for more options.") when Option::UPDATE_MODE option.validate! with_concurrent_modification_handling do update_eb_schedules end Logger.instance.log("write", "scheduled tasks updated") when Option::CLEAR_MODE with_concurrent_modification_handling do clear_tasks end Logger.instance.log("write", "scheduled tasks cleared") when Option::LIST_MODE list_tasks Logger.instance.("Above is your scheduled tasks.") when Option::PRINT_VERSION_MODE print_version end SUCCESS_EXIT_CODE rescue Aws::Errors::MissingRegionError Logger.instance.fail("missing region error occurred; please use `--region` option or export `AWS_REGION` environment variable.") ERROR_EXIT_CODE rescue Aws::Errors::MissingCredentialsError Logger.instance.fail("missing credential error occurred; please specify it with arguments, use shared credentials, or export `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variable") ERROR_EXIT_CODE rescue OptionParser::MissingArgument, Option::InvalidOptionException => e Logger.instance.fail(e.) ERROR_EXIT_CODE end |