Skip to content
Browse files

feature: Provide --all option for working with single files.

Merge branch 'FND-shortcut'
  • Loading branch information...
2 parents dab8c58 + 1afc85c commit d610ea3b7e35554b37001f697cc05e691687b1f0 @xaviershay xaviershay committed Oct 21, 2012
Showing with 25 additions and 0 deletions.
  1. +1 −0 README.md
  2. +12 −0 lib/cane/cli/parser.rb
  3. +12 −0 spec/parser_spec.rb
View
1 README.md
@@ -52,6 +52,7 @@ Customize behaviour with a wealth of options:
--gte FILE,THRESHOLD If FILE contains a number, verify it is >= to THRESHOLD
+ -f, --all FILE Apply all checks to given file
--max-violations VALUE Max allowed violations (default: 0)
--parallel Use all processors. Slower on small projects, faster on large.
View
12 lib/cane/cli/parser.rb
@@ -28,6 +28,7 @@ def initialize(stdout = $stdout)
Cane.default_checks.each do |check|
add_check_options(check)
end
+ add_checks_shortcut
add_cane_options
@@ -116,6 +117,17 @@ def add_cane_options
parser.separator ""
end
+ def add_checks_shortcut
+ description = "Apply all checks to given file"
+ parser.on("-f", "--all FILE", description) do |f|
+ # This is a bit of a hack, but provides a really useful UI for
+ # dealing with single files. Let's see how it evolves.
+ options[:abc_glob] = f
+ options[:style_glob] = f
+ options[:doc_glob] = f
+ end
+ end
+
def add_version
parser.on_tail("-v", "--version", "Show version") do
stdout.puts Cane::VERSION
View
12 spec/parser_spec.rb
@@ -27,6 +27,18 @@ def run(cli_args)
result[:max_violations].should == 1
end
+ it 'uses positional arguments as shortcut for individual files' do
+ output, result = run("--all mysinglefile")
+ result[:abc_glob].should == 'mysinglefile'
+ result[:style_glob].should == 'mysinglefile'
+ result[:doc_glob].should == 'mysinglefile'
+
+ output, result = run("--all mysinglefile --abc-glob myotherfile")
+ result[:abc_glob].should == 'myotherfile'
+ result[:style_glob].should == 'mysinglefile'
+ result[:doc_glob].should == 'mysinglefile'
+ end
+
it 'displays a help message' do
output, result = run("--help")

0 comments on commit d610ea3

Please sign in to comment.
Something went wrong with that request. Please try again.