Permalink
Browse files

added `--all` as shortcut to perform all checks on an individual file

not perfect (cf. inline comment) - suggestions for improvement welcome
  • Loading branch information...
1 parent 4735ab1 commit 212cff7830d72b0501119bde033a43459006f548 @FND FND committed Oct 18, 2012
Showing with 23 additions and 0 deletions.
  1. +11 −0 lib/cane/cli/parser.rb
  2. +12 −0 spec/parser_spec.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,16 @@ 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|
+ # XXX: hard-coded
+ 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
@@ -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 212cff7

Please sign in to comment.