Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/kafo/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Configuration
ScenarioOption::ANSWER_FILE => './config/answers.yaml',
ScenarioOption::INSTALLER_DIR => '.',
ScenarioOption::MODULE_DIRS => ['./modules'],
ScenarioOption::COLORS => Kafo::ColorScheme.colors_possible?,
ScenarioOption::COLORS => nil,
ScenarioOption::COLOR_OF_BACKGROUND => :dark,
ScenarioOption::HOOK_DIRS => [],
ScenarioOption::CHECK_DIRS => nil,
Expand Down Expand Up @@ -107,6 +107,10 @@ def app
end
end

def use_colors?
app.fetch(ScenarioOption::COLORS) { Kafo::ColorScheme.colors_possible? }
end

def get_custom(key)
custom_storage[key.to_sym]
end
Expand Down
8 changes: 5 additions & 3 deletions lib/kafo/kafo_configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ def help(*args)

def use_colors?
if config
config.app[:colors]
config.use_colors?
elsif ARGV.include?('--no-colors')
false
elsif ARGV.include?('--colors')
true
else
Kafo::ColorScheme.colors_possible?
end
end

Expand Down Expand Up @@ -190,7 +192,7 @@ def execute
parse_cli_arguments

if !config.app[:verbose]
@progress_bar = config.app[:colors] ? ProgressBars::Colored.new : ProgressBars::BlackWhite.new
@progress_bar = config.use_colors? ? ProgressBars::Colored.new : ProgressBars::BlackWhite.new
end

if checks_only? || !skip_checks_i_know_better?
Expand Down Expand Up @@ -352,7 +354,7 @@ def terminal_log_levels_message

def set_app_options
app_option ['--[no-]colors'], :flag, 'Use color output on STDOUT',
:default => config.app[:colors], :advanced => true
:default => config.use_colors?, :advanced => true
app_option ['--color-of-background'], 'COLOR', 'Your terminal background is :bright or :dark',
:default => config.app[:color_of_background], :advanced => true
app_option ['--dont-save-answers'], :flag, "Skip saving answers to '#{self.class.config.answer_file}'?",
Expand Down