Class: Pragmater::CLI
- Inherits:
-
Thor
- Object
- Thor
- Pragmater::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/pragmater/cli.rb
Overview
The Command Line Interface (CLI) for the gem.
Class Method Summary collapse
Instance Method Summary collapse
- #add(path = ".") ⇒ Object
- #config ⇒ Object
- #help(task = nil) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
A new instance of CLI.
- #remove(path = ".") ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Returns a new instance of CLI.
28 29 30 31 32 33 |
# File 'lib/pragmater/cli.rb', line 28 def initialize args = [], = {}, config = {} super args, , config @configuration = self.class.configuration rescue Runcom::Errors::Base => error abort error. end |
Class Method Details
.configuration ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pragmater/cli.rb', line 15 def self.configuration Runcom::Configuration.new project_name: Identity.name, defaults: { add: { comments: "", includes: [] }, remove: { comments: "", includes: [] } } end |
Instance Method Details
#add(path = ".") ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pragmater/cli.rb', line 47 def add path = "." settings = configuration.merge add: { comments: [:comments], includes: [:includes] } runner = Runner.new path, comments: settings.dig(:add, :comments), includes: settings.dig(:add, :includes) runner.run(action: :add) { |file| say_status :info, "Processed: #{file}.", :green } end |
#config ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/pragmater/cli.rb', line 95 def config path = configuration.path 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
113 114 115 |
# File 'lib/pragmater/cli.rb', line 113 def help task = nil say and super end |
#remove(path = ".") ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/pragmater/cli.rb', line 72 def remove path = "." settings = configuration.merge remove: { comments: [:comments], includes: [:includes] } runner = Runner.new path, comments: settings.dig(:remove, :comments), includes: settings.dig(:remove, :includes) runner.run(action: :remove) { |file| say_status :info, "Processed: #{file}.", :green } end |
#version ⇒ Object
107 108 109 |
# File 'lib/pragmater/cli.rb', line 107 def version say Identity.version_label end |