Sha256: 4df14af375f223f24b6f97d5254ecc3fecc9208781c3f96076096794b2ee4041

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

module Xing
  class CLI
    SUPPORTED_VERBS = %w{new}
    #SUPPORTED_VERBS = %w{new scaffold}
    require 'trollop'

    BANNER = <<-EOS
Xing Framework new project and code generator.  See http://github.com/XingFramework/xing-framework for platform info.

Usage:
    xing [options] <command> [command options]

Supported commands currently include: #{SUPPORTED_VERBS.join(", ")}

Examples:
    xing new fabulous   # Generates a new Xing Framework project called 'fabulous'

Global Options:
    EOS

    def handle_cli
      Trollop::options do
        banner BANNER
        framework_version =
          begin
            Gem::Specification.find_by_name("xing-framework").version
          rescue Gem::LoadError
            "<developement-version>"
          end
        version "Xing CLI #{framework_version} (c) 2015 Logical Reality Design, Inc."
        stop_on SUPPORTED_VERBS
      end

      command = ARGV.shift
      case command
      when 'new'
        opts = Trollop::options do
          opt :cms, "Include content management architecture. (coming soon)"
          opt :ruby_version, "Set the ruby version used for the new project (e.g. 2.2)", :type => :string
          stop_on ['name']
        end
        name = ARGV.shift
        Trollop::die "Please specify a project name with 'xing new <name>'" unless name
        Trollop::die "The CMS option is not yet implemented." if opts[:cms]
        if opts[:ruby_version].nil?
          opts[:ruby_version] = RbConfig::CONFIG.values_at("MAJOR","MINOR").join(".")
        end
        generator = Xing::CLI::Generators::NewProject.new
        generator.target_name = name
        generator.ruby_version = opts[:ruby_version]
        generator.generate
      else
        Trollop::die "Unknown command.  Supported commands are [" + SUPPORTED_VERBS.join(" ") + "]"
      end

    end
  end
end

require 'xing/cli/generators'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xing-framework-0.2.3 lib/xing/cli.rb
xing-framework-0.2.2 lib/xing/cli.rb
xing-framework-0.2.1 lib/xing/cli.rb
xing-framework-0.2.0 lib/xing/cli.rb
xing-framework-0.0.3 lib/xing/cli.rb
xing-framework-0.0.2 lib/xing/cli.rb