Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.

Commit 4bef318

Browse files
Mehdi LahmamTyson Gach
Mehdi Lahmam
authored and
Tyson Gach
committed
Use Thor and add --version command
Closes #315
1 parent d0978da commit 4bef318

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

bin/neat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
require "neat"
3+
require File.dirname(__FILE__) + "/../lib/neat.rb"
44

5-
Neat::Generator.new(ARGV).run
5+
Neat::Generator.start

lib/neat/generator.rb

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
require "neat/version"
12
require "fileutils"
3+
require "thor"
24

35
module Neat
4-
class Generator
5-
def initialize(arguments)
6-
@subcommand = arguments.first
7-
end
6+
class Generator < Thor
7+
map ["-v", "--version"] => :version
88

9-
def run
10-
if @subcommand == "install"
11-
install
12-
elsif @subcommand == "update"
13-
update
14-
elsif @subcommand == "remove"
15-
remove
9+
desc "install", "Install Neat into your project"
10+
def install
11+
if neat_files_already_exist?
12+
puts "Neat files already installed, doing nothing."
13+
else
14+
install_files
15+
puts "Neat files installed to neat/"
1616
end
1717
end
1818

19+
desc "update", "Update Neat"
1920
def update
2021
if neat_files_already_exist?
2122
remove_neat_directory
@@ -26,15 +27,7 @@ def update
2627
end
2728
end
2829

29-
def install
30-
if neat_files_already_exist?
31-
puts "Neat files already installed, doing nothing."
32-
else
33-
install_files
34-
puts "Neat files installed to neat/"
35-
end
36-
end
37-
30+
desc "update", "Remove Neat"
3831
def remove
3932
if neat_files_already_exist?
4033
remove_neat_directory
@@ -44,6 +37,11 @@ def remove
4437
end
4538
end
4639

40+
desc "version", "Show Neat version"
41+
def version
42+
say "Neat #{Neat::VERSION}"
43+
end
44+
4745
private
4846

4947
def neat_files_already_exist?

neat.gemspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ enough to use out of the box and flexible enough to customize down the road.
2323
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
2424
s.require_paths = ['lib']
2525

26-
s.add_dependency('sass', '>= 3.3')
2726
s.add_dependency('bourbon', '>= 4.0')
27+
s.add_dependency('sass', '>= 3.3')
28+
s.add_dependency("thor", "~> 0.19")
2829

2930
s.add_development_dependency("scss_lint", "~> 0.43")
3031
s.add_development_dependency('aruba', '~> 0.5.0')

0 commit comments

Comments
 (0)