Permalink
Browse files

Use Thor and add `--version` command

Closes #315
  • Loading branch information...
1 parent d0978da commit 4bef318692d2e0ba62112c6a2e7bc85e1e40f69d @mehlah mehlah committed with tysongach Mar 30, 2015
Showing with 22 additions and 23 deletions.
  1. +2 −2 bin/neat
  2. +18 −20 lib/neat/generator.rb
  3. +2 −1 neat.gemspec
View
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require "neat"
+require File.dirname(__FILE__) + "/../lib/neat.rb"
-Neat::Generator.new(ARGV).run
+Neat::Generator.start
View
@@ -1,21 +1,22 @@
+require "neat/version"
require "fileutils"
+require "thor"
module Neat
- class Generator
- def initialize(arguments)
- @subcommand = arguments.first
- end
+ class Generator < Thor
+ map ["-v", "--version"] => :version
- def run
- if @subcommand == "install"
- install
- elsif @subcommand == "update"
- update
- elsif @subcommand == "remove"
- remove
+ desc "install", "Install Neat into your project"
+ def install
+ if neat_files_already_exist?
+ puts "Neat files already installed, doing nothing."
+ else
+ install_files
+ puts "Neat files installed to neat/"
end
end
+ desc "update", "Update Neat"
def update
if neat_files_already_exist?
remove_neat_directory
@@ -26,15 +27,7 @@ def update
end
end
- def install
- if neat_files_already_exist?
- puts "Neat files already installed, doing nothing."
- else
- install_files
- puts "Neat files installed to neat/"
- end
- end
-
+ desc "update", "Remove Neat"
def remove
if neat_files_already_exist?
remove_neat_directory
@@ -44,6 +37,11 @@ def remove
end
end
+ desc "version", "Show Neat version"
+ def version
+ say "Neat #{Neat::VERSION}"
+ end
+
private
def neat_files_already_exist?
View
@@ -23,8 +23,9 @@ enough to use out of the box and flexible enough to customize down the road.
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ['lib']
- s.add_dependency('sass', '>= 3.3')
s.add_dependency('bourbon', '>= 4.0')
+ s.add_dependency('sass', '>= 3.3')
+ s.add_dependency("thor", "~> 0.19")
s.add_development_dependency("scss_lint", "~> 0.43")
s.add_development_dependency('aruba', '~> 0.5.0')

0 comments on commit 4bef318

Please sign in to comment.