Module: SupermarketSync::CLI
- Defined in:
- lib/supermarket_sync/cli.rb
Overview
> SupermarketSync Launcher
Defined Under Namespace
Classes: Options
Class Method Summary collapse
-
.run(argv = ARGV) ⇒ Object
> Launch the Application.
Class Method Details
.run(argv = ARGV) ⇒ Object
> Launch the Application
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/supermarket_sync/cli.rb', line 41 def run(argv = ARGV) # rubocop: disable AbcSize, MethodLength # # => Parse CLI Configuration # cli = Options.new cli.(argv) # => Grab the Default Values default = Config. # => Parse JSON Config File (If Specified and Exists) json_config = Util.parse_json(cli.config[:config_file] || Config.config_file) # => Merge Configuration (CLI Wins) config = [default, json_config, cli.config].compact.reduce(:merge) # => Apply Configuration Config.setup do |cfg| cfg.cookbooks_file = config[:cookbooks_file] cfg.notification = config[:notification] cfg.supermarkets = config[:supermarkets] cfg.source = config[:source] cfg.read_only = config[:read_only] end # => Start the Sync Sync.run! end |