Class: SimplyGenius::Atmos::CLI

Inherits:
Clamp::Command
  • Object
show all
Includes:
GemLogger::LoggerSupport
Defined in:
lib/simplygenius/atmos/cli.rb

Overview

The command line interface to atmos

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/simplygenius/atmos/cli.rb', line 18

def self.description
  desc = <<-DESC
    Atmos version #{VERSION}
    
    Runs The atmos command line application
    
    e.g.
    
    atmos --help
  DESC
  desc.split("\n").collect(&:strip).join("\n")
end

.run(*args, **opts, &blk) ⇒ Object



126
127
128
129
130
131
132
133
134
# File 'lib/simplygenius/atmos/cli.rb', line 126

def run(*args, **opts, &blk)
  begin
    super
  rescue Exception => e
    logger.log_exception(e, "Unhandled exception", level: :debug)
    logger.error(e.message)
    exit!
  end
end

Instance Method Details

#default_color?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/simplygenius/atmos/cli.rb', line 54

def default_color?
   $stdout.tty?
end

#parse(arguments) ⇒ Object

hook into clamp lifecycle to force logging setup even when we are calling a subcommand



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/simplygenius/atmos/cli.rb', line 106

def parse(arguments)
  super
  if Atmos.config.nil?
    Atmos.config = Config.new(atmos_env, atmos_group)
    log = Atmos.config.is_atmos_repo? && log? ? "atmos.log" : nil
    level = :info
    level = :debug if debug?
    level = :error if quiet?

    Logging.setup_logging(level, color?, log)

    UI.color_enabled = color?

    Atmos.config.add_user_load_path(*load_path_list)
    Atmos.config.plugin_manager.load_plugins
  end
end