class Parser

This class is just a wrapper for the main process of ngi

Constants

COMPONENTS
COMPONENTS_FILE
COMPONENTS_HASH
CONFIGURABLE
CONFIGURABLE_FILE
CONFIG_FILE
CONFIG_HASH
CURRENT_DIR
LANGUAGES_FILE
LANGUAGES_HASH

Public Class Methods

parse(args) click to toggle source
# File lib/ngi/parser.rb, line 58
def self.parse(args)
  p = Utils::CommandParser.new do |parser|
    components = Utils::UserInput.new(valid_inputs: COMPONENTS)

    parser.name, parser.version = 'ngi', Ngi::VERSION
    parser.banner << "\n(<command> can be one of the following)"

    parser.on(components.valid_inputs, 'Create a new component') do |type|
      component = ComponentChooser
                  .new(
                    type: type,
                    components_hash: COMPONENTS_HASH,
                    config_hash: CONFIG_HASH
                  )
                  .component

      Delegate::Generator.run(
        type: type,
        config: CONFIG_HASH,
        component: component
      )
    end

    parser.on(['-o', '--options'], 'Configure ngi') do
      Delegate::Configure.run(
        write: true,
        to: 'yaml',
        destination: CONFIG_FILE,
        languages: LANGUAGES_HASH,
        config: CONFIG_HASH,
        components: COMPONENTS,
        components_hash: COMPONENTS_HASH,
        configurable: CONFIGURABLE
      )
    end
  end

  p.parse(args)
end