From e44ee68b1dced2572bb91fd300bd416e7eacf589 Mon Sep 17 00:00:00 2001 From: Jamon Holmgren Date: Wed, 16 Oct 2013 23:13:49 -0700 Subject: [PATCH] Added pm binary with command. --- Gemfile.lock | 3 +++ ProMotion.gemspec | 7 +++++-- bin/pm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 bin/pm diff --git a/Gemfile.lock b/Gemfile.lock index 4420ec0..92c968b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,6 +2,7 @@ PATH remote: . specs: ProMotion (1.0.4) + methadone GEM remote: https://rubygems.org/ @@ -10,6 +11,8 @@ GEM formotion (1.3.1) bubble-wrap (>= 1.1.4) motion-require (~> 0.0.3) + methadone (1.3.0) + bundler motion-redgreen (0.1.0) motion-require (0.0.6) motion-stump (0.2.1) diff --git a/ProMotion.gemspec b/ProMotion.gemspec index c99539f..bcf68ed 100644 --- a/ProMotion.gemspec +++ b/ProMotion.gemspec @@ -15,8 +15,10 @@ Gem::Specification.new do |gem| gem.license = 'MIT' gem.files = `git ls-files`.split($\) - gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + # gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + # gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) } + gem.executables << "pm" + gem.test_files = gem.files.grep(%r{^(spec)/}) gem.name = "ProMotion" gem.require_paths = ["lib"] gem.version = ProMotion::VERSION @@ -26,4 +28,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency("motion-redgreen") gem.add_development_dependency("formotion") gem.add_development_dependency("rake") + gem.add_dependency("methadone") end diff --git a/bin/pm b/bin/pm new file mode 100755 index 0000000..83ad6b6 --- /dev/null +++ b/bin/pm @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +require 'optparse' +require 'methadone' +require 'ProMotion/version' + +class App + include Methadone::Main + include Methadone::CLILogging + include Methadone::SH + + main do |command, opt| + case command.to_sym + when :new then create(opt) + when :help then show_help + else show_help + end + + 0 # Good! + end + + def self.show_help + info "pm - Command line tools for ProMotion." + info "By Jamon Holmgren" + info "" + info "Commands:" + info " new " + info " Creates a new ProMotion app from a template." + end + + def self.create(name) + return puts "Usage: pm new " unless name.to_s.length > 0 + info "Creating new ProMotion iOS app #{name}" + sh "motion create --template=git@github.com:jamonholmgren/promotion-template.git #{name}" + end + + description "Command line for ProMotion." + + arg :command + arg :opt, :optional + + version ProMotion::VERSION + + go! +end