Class: Ace::B36ts::Commands::ConfigCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/b36ts/commands/config_command.rb

Overview

Command to display current configuration

Examples:

Usage

ConfigCommand.execute
# Output:
# year_zero: 2000
# alphabet: 0123456789abcdefghijklmnopqrstuvwxyz

Class Method Summary collapse

Class Method Details

.execute(options = {}) ⇒ Integer

Execute the config command

Parameters:

  • options (Hash) (defaults to: {})

    Command options

Options Hash (options):

  • :verbose (Boolean)

    Show additional config details

Returns:

  • (Integer)

    Exit code (0 for success)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ace/b36ts/commands/config_command.rb', line 21

def execute(options = {})
  config = Molecules::ConfigResolver.resolve

  puts "Current ace-b36ts configuration:"
  puts ""
  puts "  year_zero: #{config[:year_zero]}"
  puts "  alphabet: #{config[:alphabet]}"

  if options[:verbose]
    puts ""
    puts "Configuration sources (in order of precedence):"
    puts "  1. Runtime options (passed to commands)"
    puts "  2. Project config: .ace/b36ts/config.yml"
    puts "  3. User config: ~/.ace/b36ts/config.yml"
    puts "  4. Gem defaults: .ace-defaults/b36ts/config.yml"
    puts ""
    puts "Year range: #{config[:year_zero]} to #{config[:year_zero] + 107}"
    puts "ID length: 6 characters (Base36)"
    puts "Time precision: ~1.85 seconds"
  end

  0
rescue => e
  warn "Error displaying config: #{e.message}"
  warn e.backtrace.first(5).join("\n") if Ace::B36ts.debug?
  raise
end