lib/pragmater/cli.rb in pragmater-4.1.0 vs lib/pragmater/cli.rb in pragmater-4.2.0
- old
+ new
@@ -25,10 +25,13 @@
}
end
def initialize args = [], options = {}, config = {}
super args, options, config
+ @configuration = self.class.configuration
+ rescue Runcom::Errors::Base => error
+ abort error.message
end
desc "-a, [--add=PATH]", "Add pragma comments to source file(s)."
map %w[-a --add] => :add
method_option :comments,
@@ -40,11 +43,11 @@
aliases: "-w",
desc: "File whitelist",
type: :array,
default: []
def add path = "."
- settings = self.class.configuration.merge add: {
+ settings = configuration.merge add: {
comments: options[:comments],
whitelist: options[:whitelist]
}
runner = Runner.new path,
@@ -65,11 +68,11 @@
aliases: "-w",
desc: "File whitelist",
type: :array,
default: []
def remove path = "."
- settings = self.class.configuration.merge remove: {
+ settings = configuration.merge remove: {
comments: options[:comments],
whitelist: options[:whitelist]
}
runner = Runner.new path,
@@ -88,11 +91,11 @@
method_option :info,
aliases: "-i",
desc: "Print gem configuration.",
type: :boolean, default: false
def config
- path = self.class.configuration.path
+ path = configuration.path
if options.edit? then `#{ENV["EDITOR"]} #{path}`
elsif options.info?
path ? say(path) : say("Configuration doesn't exist.")
else help(:config)
@@ -108,7 +111,11 @@
desc "-h, [--help=COMMAND]", "Show this message or get help for a command."
map %w[-h --help] => :help
def help task = nil
say and super
end
+
+ private
+
+ attr_reader :configuration
end
end