Add quiet mode

Only log errors
This commit is contained in:
David Heinemeier Hansson
2023-02-01 14:10:51 +01:00
parent cdd77445d0
commit f06d639583
3 changed files with 14 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ module Mrsk::Cli
def self.exit_on_failure?() true end
class_option :verbose, type: :boolean, aliases: "-v", desc: "Detailed logging"
class_option :quiet, type: :boolean, aliases: "-q", desc: "Minimal logging"
class_option :version, desc: "Run commands against a specific app version"
@@ -35,8 +36,12 @@ module Mrsk::Cli
commander.specific_primary! if options[:primary]
if options[:verbose]
commander.verbose = true
ENV["VERBOSE"] = "1" # For backtraces via cli/start
ENV["VERBOSE"] = "1" # For backtraces via cli/start
commander.verbosity = :debug
end
if options[:quiet]
commander.verbosity = :error
end
end
end

View File

@@ -13,13 +13,13 @@ class Mrsk::Cli::Build < Mrsk::Cli::Base
run_locally do
begin
MRSK.verbosity(:debug) { execute *MRSK.builder.push }
MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
rescue SSHKit::Command::Failed => e
if e.message =~ /(no builder)|(no such file or directory)/
error "Missing compatible builder, so creating a new one first"
if cli.create
MRSK.verbosity(:debug) { execute *MRSK.builder.push }
MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
end
else
raise