Permalink
Browse files

Implement exec command

  • Loading branch information...
Shohei Yamasaki
Shohei Yamasaki committed Jun 23, 2016
1 parent 3ddebb2 commit a11c3c7f4daf1ddf26c0ab4f4ae9d8b1b78bda4b
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/checkstyle_filter/git/cli.rb
@@ -29,6 +29,19 @@ def diff(commit_ish = nil)
puts ::CheckstyleFilter::Git::Filter.filter(data, git_diff)
end
+ desc 'exec', 'Exec command `"git diff --no-color origin/master | iconv -f EUCJP -t UTF8"`'
+ def exec(command)
+ data = if !$stdin.tty?
+ ARGV.clear
+ ARGF.read
+ end
+
+ abort if !data || data.empty?
+
+ git_diff, _, _ = Open3.capture3(command)
+ puts ::CheckstyleFilter::Git::Filter.filter(data, git_diff)
+ end
+
desc 'version', 'Show the CheckstyleFilter/Git version'
map %w(-v --version) => :version

0 comments on commit a11c3c7

Please sign in to comment.