Sha256: 6e7f09b8d9c0f6855ac651030f6c5504106384e1c7bc97d5019ebdd15dd869f6
Contents?: true
Size: 1.22 KB
Versions: 19
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Command class Config < Base NAME = "config" OPTIONS = [ app_option ].freeze DESCRIPTION = "Displays config for each app or a specific app" LONG_DESCRIPTION = <<~DESC - Displays config for each app or a specific app DESC EXAMPLES = <<~EX ```sh # Shows the config for each app. cpl config # Shows the config for a specific app. cpl config -a $APP_NAME ``` EX def call # rubocop:disable Metrics/MethodLength if config.app puts "#{Shell.color("Current config (app '#{config.app}')", :blue)}:" puts pretty_print(config.current) puts else config.apps.each do |app_name, app_options| puts "#{Shell.color("Config for app '#{app_name}'", :blue)}:" puts pretty_print(app_options) puts end end end private def pretty_print(hash) hash.transform_keys(&:to_s) .to_yaml(indentation: 2)[4..] # Adds an indentation of 2 to the beginning of each line .gsub(/^(\s*)/, " \\1") # Adds an indentation of 2 before the '-' in array items .gsub(/^(\s*)-\s/, "\\1 - ") end end end
Version data entries
19 entries across 19 versions & 1 rubygems