Sha256: a5a1b1f0601fca092e401ac625b055def42d69794df1feb8fb31a7ef0a49c649

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby

# angular_init (short-name: ngi)
# Copyright 2015 Joshua Beam
# github.com/joshbeam/angular_init
# MIT License

# Ngi is the main module (src/ruby/angular_init.rb)
require_relative '../lib/ngi'
require_relative '../lib/ngi/utils/utils'

# This class is just a wrapper for the main process
# of ngi
class Parser
  CURRENT_DIR = File.dirname(__FILE__)
  def self.parse(args)
    p = Utils::CommandParser.new do |parser|
      config_file = "#{CURRENT_DIR}/../lib/config/angular_init.config.json"
      config = Ngi::Delegate::Configure.new(config_file).from_json
      components = config['global']['components'].collect { |t| t['name'] }
      types = Ngi::UserInput.new(valid_inputs: components)

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

      parser.on(types.valid_inputs, 'Create a new component') do |command|
        Ngi::Delegate::Generator.run(type: command, config: config)
      end

      parser.on(['-o', '--options'], 'Configure ngi') do
        Ngi::Delegate::Configure.run(write: true, file_path: config_file)
      end
    end

    p.parse(args)
  end
end

Parser.parse(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ngi-0.2.3 bin/ngi