Add quiet mode
Only log errors
This commit is contained in:
@@ -8,6 +8,7 @@ module Mrsk::Cli
|
|||||||
def self.exit_on_failure?() true end
|
def self.exit_on_failure?() true end
|
||||||
|
|
||||||
class_option :verbose, type: :boolean, aliases: "-v", desc: "Detailed logging"
|
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"
|
class_option :version, desc: "Run commands against a specific app version"
|
||||||
|
|
||||||
@@ -35,8 +36,12 @@ module Mrsk::Cli
|
|||||||
commander.specific_primary! if options[:primary]
|
commander.specific_primary! if options[:primary]
|
||||||
|
|
||||||
if options[:verbose]
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ class Mrsk::Cli::Build < Mrsk::Cli::Base
|
|||||||
|
|
||||||
run_locally do
|
run_locally do
|
||||||
begin
|
begin
|
||||||
MRSK.verbosity(:debug) { execute *MRSK.builder.push }
|
MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
|
||||||
rescue SSHKit::Command::Failed => e
|
rescue SSHKit::Command::Failed => e
|
||||||
if e.message =~ /(no builder)|(no such file or directory)/
|
if e.message =~ /(no builder)|(no such file or directory)/
|
||||||
error "Missing compatible builder, so creating a new one first"
|
error "Missing compatible builder, so creating a new one first"
|
||||||
|
|
||||||
if cli.create
|
if cli.create
|
||||||
MRSK.verbosity(:debug) { execute *MRSK.builder.push }
|
MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ require "mrsk/commands/traefik"
|
|||||||
require "mrsk/commands/registry"
|
require "mrsk/commands/registry"
|
||||||
|
|
||||||
class Mrsk::Commander
|
class Mrsk::Commander
|
||||||
attr_accessor :config_file, :destination, :verbose, :version
|
attr_accessor :config_file, :destination, :verbosity, :version
|
||||||
|
|
||||||
def initialize(config_file: nil, destination: nil, verbose: false)
|
def initialize(config_file: nil, destination: nil, verbosity: :info)
|
||||||
@config_file, @destination, @verbose = config_file, destination, verbose
|
@config_file, @destination, @verbosity = config_file, destination, verbosity
|
||||||
end
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
@@ -78,7 +78,7 @@ class Mrsk::Commander
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def verbosity(level)
|
def with_verbosity(level)
|
||||||
old_level = SSHKit.config.output_verbosity
|
old_level = SSHKit.config.output_verbosity
|
||||||
SSHKit.config.output_verbosity = level
|
SSHKit.config.output_verbosity = level
|
||||||
yield
|
yield
|
||||||
@@ -95,6 +95,6 @@ class Mrsk::Commander
|
|||||||
def configure_sshkit_with(config)
|
def configure_sshkit_with(config)
|
||||||
SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = config.ssh_options }
|
SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = config.ssh_options }
|
||||||
SSHKit.config.command_map[:docker] = "docker" # No need to use /usr/bin/env, just clogs up the logs
|
SSHKit.config.command_map[:docker] = "docker" # No need to use /usr/bin/env, just clogs up the logs
|
||||||
SSHKit.config.output_verbosity = :debug if verbose
|
SSHKit.config.output_verbosity = verbosity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user