Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
Refactor the main app-y bits into a method that can be called more di…
Browse files Browse the repository at this point in the history
…rectly.
  • Loading branch information
coderanger committed Apr 6, 2017
1 parent 3a0fee0 commit b7a9ee6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 1 addition & 7 deletions bin/foodcritic
@@ -1,9 +1,3 @@
#!/usr/bin/env ruby
require_relative "../lib/foodcritic"
module FoodCritic
cmd_line = CommandLine.new(ARGV)
review, status = Linter.run(cmd_line)
printer = cmd_line.show_context? ? ContextOutput.new : SummaryOutput.new
printer.output(review)
exit status.to_i
end
exit FoodCritic::CommandLine.main
9 changes: 9 additions & 0 deletions lib/foodcritic/command_line.rb
@@ -1,6 +1,15 @@
module FoodCritic
# Command line parsing.
class CommandLine
def self.main(argv=ARGV, out=$stdout)
cmd_line = CommandLine.new(argv)
review, status = Linter.run(cmd_line)
printer = cmd_line.show_context? ? ContextOutput.new(out) : SummaryOutput.new(out)
printer.output(review)
status.to_i
end


# Create a new instance of CommandLine
#
# @param [Array] args The command line arguments
Expand Down

0 comments on commit b7a9ee6

Please sign in to comment.