Class: Git::Lint::CLI
- Inherits:
-
Thor
- Object
- Thor
- Git::Lint::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/git/lint/cli.rb
Overview
The Command Line Interface (CLI) for the gem.
Class Method Summary collapse
Instance Method Summary collapse
- #analyze ⇒ Object
- #config ⇒ Object
- #help(task = nil) ⇒ Object
- #hook ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
A new instance of CLI.
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Returns a new instance of CLI.
25 26 27 28 29 30 31 32 |
# File 'lib/git/lint/cli.rb', line 25 def initialize args = [], = {}, config = {} super args, , config @configuration = self.class.configuration @runner = Runner.new configuration: @configuration.to_h @colorizer = Pastel.new rescue Runcom::Errors::Base => error abort error. end |
Class Method Details
.configuration ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/git/lint/cli.rb', line 17 def self.configuration defaults = Analyzers::Abstract.descendants.reduce({}) do |settings, analyzer| settings.merge analyzer.id => analyzer.defaults end Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: defaults end |
Instance Method Details
#analyze ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/git/lint/cli.rb', line 63 def analyze # FIX: Need to accept SHAs. # collector = analyze_commits options.commits collector = analyze_commits abort if collector.errors? rescue Errors::Base => error abort colorizer.red("#{Identity::LABEL}: #{error.}") end |
#config ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/git/lint/cli.rb', line 46 def config path = configuration.current if .edit? then `#{ENV["EDITOR"]} #{path}` elsif .info? path ? say(path) : say("Configuration doesn't exist.") else help :config end end |
#help(task = nil) ⇒ Object
96 97 98 |
# File 'lib/git/lint/cli.rb', line 96 def help task = nil say and super end |
#hook ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/git/lint/cli.rb', line 78 def hook if . . else help "--hook" end rescue Errors::Base, GitPlus::Errors::Base => error abort colorizer.red("#{Identity::LABEL}: #{error.}") end |
#version ⇒ Object
90 91 92 |
# File 'lib/git/lint/cli.rb', line 90 def version say Identity::VERSION_LABEL end |