Skip to content

Commit

Permalink
Rename --debug to --verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfierke committed Jul 3, 2024
1 parent 3501785 commit 9ce8834
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If applicable, add logs or screenshots to help explain your problem. **Please re
Add any other context about the problem here.

**Checklist**
- [ ] I have tried running with `--debug` and troubleshooting based on that output
- [ ] I have tried running with `--verbose` and troubleshooting based on that output
- [ ] I have provided relevant steps to reproduce
- [ ] I have provided a log file and/or screenshots and have verified there is nothing sensitive
- [ ] I am not asking for general troubleshooting/assistance with using the software
2 changes: 1 addition & 1 deletion .github/workflows/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
env:
STRAP_CI: true
run: |
bin/mstrap --debug \
bin/mstrap --verbose \
--config ${{ secrets.TEST_CONFIG_URL }}
- name: Install required dependencies for ruby
Expand Down
2 changes: 1 addition & 1 deletion spec/provisioning/docker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export USER="$(whoami)"
export SHELL=/bin/bash
export STRAP_CI=true

MSTRAP_FLAGS=${MSTRAP_FLAGS:-"--debug"}
MSTRAP_FLAGS=${MSTRAP_FLAGS:-"--verbose"}
WORKSPACE=/workspace

mkdir -p ~/.ssh && chmod 700 ~/.ssh
Expand Down
20 changes: 9 additions & 11 deletions src/mstrap.cr
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,22 @@ module MStrap
end
end

@@debug = false
@@verbose = false

# Set debug mode for `mstrap`
def self.debug=(value)
@@debug = value
# Set verbose mode for `mstrap`
def self.verbose=(value)
@@verbose = value
end

# Returns whether or not `mstrap` is in debug mode.
#
# NOTE: This is not the same as whether it was _compiled_ in debug mode.
def self.debug?
@@debug
# Returns whether or not `mstrap` is in verbose mode.
def self.verbose?
@@verbose
end

# Sets up Log instance that can be used to log to the mstrap log file.
# When `MStrap.debug?` is set to `true`, this also logs messages to `STDOUT`.
# When `MStrap.verbose?` is set to `true`, this also logs messages to `STDOUT`.
def self.initialize_logger! : Nil
if debug?
if verbose?
FileUtils.mkdir_p(Paths::RC_DIR, 0o755)
log_file = File.new(MStrap::Paths::LOG_FILE, "a+")
writer = IO::MultiWriter.new(log_file, STDOUT)
Expand Down
19 changes: 14 additions & 5 deletions src/mstrap/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ DESC
end

cmd.flags.add do |flag|
flag.name = "debug"
flag.short = "-d"
flag.long = "--debug"
flag.name = "verbose"
flag.short = "-v"
flag.long = "--verbose"
flag.default = false
flag.description = "Run with debug messaging."
flag.description = "Run with verbose messaging."
flag.persistent = true
end

Expand Down Expand Up @@ -99,6 +99,15 @@ DESC
flag.persistent = true
end

cmd.flags.add do |flag|
flag.name = "version"
flag.short = "-V"
flag.long = "--version"
flag.default = false
flag.description = "Prints version number."
flag.persistent = true
end

Step.all.each do |key, step|
cmd.commands.add do |step_cmd|
step_cmd.use = key.to_s
Expand Down Expand Up @@ -266,7 +275,7 @@ DESC
end

private def load_cli_options!(options)
MStrap.debug = options.bool["debug"] if options.bool.has_key?("debug")
MStrap.verbose = options.bool["verbose"] if options.bool.has_key?("verbose")
self.options.config_path = options.string["config_path"] if options.string.has_key?("config_path")
self.options.force = options.bool["force"] if options.bool.has_key?("force")
self.options.skip_project_update = options.bool["skip_project_update"] if options.bool.has_key?("skip_project_update")
Expand Down
8 changes: 4 additions & 4 deletions src/mstrap/dsl/logging.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module MStrap
module Logging
# Logs a message, without appending a newline.
def log(msg)
return logn(msg) if MStrap.debug?
return logn(msg) if MStrap.verbose?
print msg
Log.info { msg }
end
Expand Down Expand Up @@ -34,14 +34,14 @@ module MStrap
end

# Logs a message at the FATAL level and terminate program. On a TTY, this
# will output in red. In debug, this will also print the stacktrace.
# will output in red. With --verbose, this will also print the stacktrace.
def logc(msg)
Log.fatal { msg }
if MStrap.debug?
if MStrap.verbose?
abort msg.colorize(:red)
else
puts "!!! #{msg}".colorize(:red)
puts "!!! Check #{MStrap::Paths::LOG_FILE} and/or run with --debug for more detail.".colorize(:red)
puts "!!! Check #{MStrap::Paths::LOG_FILE} and/or run with --verbose for more detail.".colorize(:red)
exit 1
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/mstrap/platform.cr
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module MStrap
error: error,
}

if MStrap.debug?
if MStrap.verbose?
named = named.merge({
input: Process::Redirect::Inherit,
output: Process::Redirect::Inherit,
Expand Down
4 changes: 2 additions & 2 deletions src/mstrap/steps/dependencies_step.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module MStrap

private def strap_sh
logn "==> Running strap.sh"
unless cmd "bash #{MStrap::Paths::STRAP_SH_PATH} #{MStrap.debug? ? "--debug" : ""}"
unless cmd "bash #{MStrap::Paths::STRAP_SH_PATH} #{MStrap.verbose? ? "--debug" : ""}"
logc "Uhh oh, something went wrong in strap.sh-land."
end
success "Finished running strap.sh"
Expand All @@ -47,7 +47,7 @@ module MStrap

if File.exists?(brewfile_path)
log "--> Installing dependencies from Brewfile from profile '#{profile_config.name})': "
unless cmd "brew bundle --file=#{brewfile_path} #{MStrap.debug? ? "--verbose" : ""}"
unless cmd "brew bundle --file=#{brewfile_path} #{MStrap.verbose? ? "--verbose" : ""}"
logc "Uhh oh, something went wrong in homebrewland."
end
success "OK"
Expand Down
2 changes: 1 addition & 1 deletion src/mstrap/supports/mise_installer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module MStrap
"MISE_INSTALL_PATH" => MISE_INSTALL_PATH,
}

if MStrap.debug?
if MStrap.verbose?
mise_env["MISE_DEBUG"] = "1"
else
mise_env["MISE_QUIET"] = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/mstrap/supports/rustup_installer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module MStrap

install_args = [RUSTUP_INIT_SH_PATH, "--no-modify-path"]

if MStrap.debug?
if MStrap.verbose?
install_args << "--verbose"
else
install_args << "--quiet"
Expand Down

0 comments on commit 9ce8834

Please sign in to comment.