Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add CLI support for `-v` and `--version` flags.

  • Loading branch information...
commit df1615d488b7d0baf04a8e4a0d49a22a56a57ce0 1 parent 008b676
@miketierney authored
View
1  README.rdoc
@@ -51,7 +51,6 @@ None
== TODO
-- CLI should support "-v" or "--version" (or both) option to print out currently active Artii version
- Allow integrated objects to accept a print out a pre-defined text value
- Ability to load non *.flf files (fonts are available, .flc file-types seem to be an issue right now)
- Ability to set custom configurations, so you don't have to constantly set the options (like font) unless you want to
View
2  artii.gemspec
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = "artii"
- s.version = "2.0.2"
+ s.version = "2.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Mike Tierney"]
View
4 lib/artii/base.rb
@@ -69,5 +69,9 @@ def all_fonts
font_faces
end
+
+ def version
+ Gem::Specification::load('artii.gemspec').version.to_s
+ end
end
end
View
4 lib/artii/cli.rb
@@ -19,6 +19,10 @@ def initialize(*args)
@action = :list_all_fonts
end
+ opts.on('-v', '--version', 'Displays current version number') do |version|
+ @action = :version
+ end
+
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
View
14 spec/artii/cli_spec.rb
@@ -71,6 +71,20 @@
end
end
+ describe "version" do
+ it "should output the version" do
+ gemspec = Gem::Specification::load 'artii.gemspec'
+ version = gemspec.version.to_s
+
+ a1 = Artii::CLI.new '-v'
+ a1.output.should_not be_empty
+ a1.output.should == version
+
+ a2 = Artii::CLI.new '--version'
+ a2.output.should_not be_empty
+ a2.output.should == version
+ end
+ end
describe "#asciify" do
it "should produce an output" do
a = Artii::CLI.new 'hello world'
Please sign in to comment.
Something went wrong with that request. Please try again.