Sha256: 23f26c06b0608040e7520d3dbe9c83595ec306707500b6bb3bbc4d3d4cea8793
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
#!/usr/bin/env ruby require 'getoptlong' require File.expand_path('../lib/nesta/commands', File.dirname(__FILE__)) module Nesta class Cli def self.usage puts <<EOF USAGE: #{File.basename($0)} [GLOBAL OPTIONS] <command> [COMMAND OPTIONS] GLOBAL OPTIONS --help, -h Display this message. COMMANDS new <path> Create a new Nesta project. theme:install <url> Install a theme from a git repository. theme:enable <name> Make the theme active, updating config.yml. theme:create <name> Makes a template for a new theme in ./themes. OPTIONS FOR new --heroku Include the heroku:config rake task. --vlad Include config/deploy.rb. EOF exit 0 end def self.parse_command_line opts = GetoptLong.new( ['--help', '-h', GetoptLong::NO_ARGUMENT], ['--heroku', GetoptLong::NO_ARGUMENT], ['--vlad', GetoptLong::NO_ARGUMENT] ) options = {} opts.each do |opt, arg| case opt when '--help' usage else options[opt.sub(/^--/, '')] = arg end end options end def self.main(options) command = ARGV.shift command.nil? && usage case command when 'new' Nesta::Commands::New.new(ARGV[0], options).execute when /^theme:(create|enable|install)$/ command_cls = Nesta::Commands::Theme.const_get($1.capitalize.to_sym) command_cls.new(ARGV[0], options).execute else usage end rescue Nesta::Commands::UsageError => e $stderr.puts "ERROR: #{e}" usage end end end Nesta::Cli.main(Nesta::Cli.parse_command_line)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nesta-0.9.0 | bin/nesta |