diff options
-rw-r--r-- | lib/oxidized.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/cli.rb | 4 | ||||
-rw-r--r-- | spec/cli_spec.rb | 24 |
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/oxidized.rb b/lib/oxidized.rb index e92224a..dfd9679 100644 --- a/lib/oxidized.rb +++ b/lib/oxidized.rb @@ -3,6 +3,7 @@ module Oxidized Directory = File.expand_path(File.join(File.dirname(__FILE__), '../')) + require 'oxidized/version' require 'oxidized/string' require 'oxidized/config' require 'oxidized/config/vars' diff --git a/lib/oxidized/cli.rb b/lib/oxidized/cli.rb index d35eab3..0594dcb 100644 --- a/lib/oxidized/cli.rb +++ b/lib/oxidized/cli.rb @@ -43,6 +43,10 @@ module Oxidized opts = Slop.new(:help=>true) do on 'd', 'debug', 'turn on debugging' on 'daemonize', 'Daemonize/fork the process' + on 'v', 'version', 'show version' do + puts Oxidized::VERSION + Kernel.exit + end end [opts.parse!, opts] end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb new file mode 100644 index 0000000..783d9c8 --- /dev/null +++ b/spec/cli_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' +require 'oxidized/cli' + +describe Oxidized::CLI do + let(:asetus) { mock() } + + after { ARGV.replace @original } + before { @original = ARGV } + + %w[-v --version].each do |option| + describe option do + before { ARGV.replace [option] } + + it 'prints the version and exits' do + Oxidized::Config.expects(:load).returns(asetus) + Kernel.expects(:exit) + + proc { + Oxidized::CLI.new + }.must_output "#{Oxidized::VERSION}\n" + end + end + end +end |