Permalink
Browse files

Use docopt to build CLI

Add aruba to spec cli behavior
  • Loading branch information...
1 parent 5b0182d commit e0a16929ed876f0bc0e8d9d21294b318ad5b67ec @LTe LTe committed Jul 10, 2012
Showing with 25 additions and 11 deletions.
  1. +1 −0 Gemfile
  2. +7 −11 bin/scanny
  3. +1 −0 scanny.gemspec
  4. +11 −0 spec/scanny/cli_spec.rb
  5. +1 −0 spec/spec_helper.rb
  6. +4 −0 spec/support/aruba.rb
View
@@ -7,4 +7,5 @@ gemspec
group :test do
gem 'rspec'
gem 'rake'
+ gem 'aruba'
end
View
@@ -1,21 +1,17 @@
#!/usr/bin/env ruby
-require "optparse"
+require "docopt"
require_relative "../lib/scanny"
-options = {}
+doc = "Scanny RoR secutiry scanner
-opt_parser = OptionParser.new do |opt|
- opt.banner = "Usage: scanny [OPTIONS] files"
- opt.separator ""
- opt.separator "Options"
+Usage:
+ scanny [options] <files_or_dirs>...
- opt.on("-h","--help","help") do
- puts opt_parser
- end
-end
+Options:
+ -h, --help Show this screen."
-opt_parser.parse!
+options = Docopt(doc)
runner = Scanny::Runner.new
reports = []
View
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "scanny"
s.add_dependency "machete", "~> 0.4.0"
+ s.add_dependency "docopt", "~> 0.0.4"
s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
View
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+describe "Command line interface" do
+ before { @help_message_prefix = "Scanny RoR secutiry scanner" }
+
+ describe "when given --help argument" do
+ before { run 'scanny --help' }
+ it { assert_partial_output @help_message_prefix, all_stdout }
+ it { assert_exit_status 0 }
+ end
+end
View
@@ -5,5 +5,6 @@
RSpec.configure do |c|
c.include CheckSpecHelpers
c.include ConstSpecHelpers
+ c.include Aruba::Api
c.color_enabled = true
end
View
@@ -0,0 +1,4 @@
+require 'aruba/api'
+
+extra_path_folder = File.join(File.expand_path(File.dirname(__FILE__)), '../bin')
+ENV['PATH'] = [extra_path_folder, ENV['PATH']].join(File::PATH_SEPARATOR)

0 comments on commit e0a1692

Please sign in to comment.