Implement CLI debug option
This commit is contained in:
@@ -18,7 +18,10 @@ module Producer
|
||||
stderr.puts e.message
|
||||
exit EX_USAGE
|
||||
rescue Exception => e
|
||||
ef = ErrorFormatter.new(force_cause: [RecipeEvaluationError])
|
||||
ef = ErrorFormatter.new(
|
||||
debug: cli.env.debug?,
|
||||
force_cause: [RecipeEvaluationError]
|
||||
)
|
||||
stderr.puts ef.format e
|
||||
exit EX_SOFTWARE
|
||||
end
|
||||
@@ -66,6 +69,10 @@ module Producer
|
||||
env.verbose = true
|
||||
end
|
||||
|
||||
opts.on '-d', '--debug', 'enable debug mode' do |e|
|
||||
env.debug = true
|
||||
end
|
||||
|
||||
opts.on '-n', '--dry-run', 'enable dry run mode' do |e|
|
||||
env.dry_run = true
|
||||
end
|
||||
|
@@ -2,10 +2,10 @@ module Producer
|
||||
module Core
|
||||
class Env
|
||||
attr_reader :input, :output, :error_output, :registry, :logger
|
||||
attr_accessor :target, :verbose, :dry_run
|
||||
attr_accessor :target, :verbose, :debug, :dry_run
|
||||
|
||||
def initialize(input: $stdin, output: $stdout, error_output: $stderr, remote: nil, registry: {})
|
||||
@verbose = @dry_run = false
|
||||
@verbose = @debug = @dry_run = false
|
||||
@input = input
|
||||
@output = output
|
||||
@error_output = error_output
|
||||
@@ -45,6 +45,10 @@ module Producer
|
||||
@verbose
|
||||
end
|
||||
|
||||
def debug?
|
||||
@debug
|
||||
end
|
||||
|
||||
def dry_run?
|
||||
@dry_run
|
||||
end
|
||||
|
Reference in New Issue
Block a user