Class: MotdForge::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/motd_forge/cli.rb

Overview

Parses CLI flags, merges in an optional YAML config, and prints the banner.

Constant Summary collapse

DEFAULT_CONFIG_PATH =
File.expand_path("~/.motd-forge.yml")

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



16
17
18
19
20
21
22
23
# File 'lib/motd_forge/cli.rb', line 16

def initialize(argv)
  @argv = argv
  @title = Socket.gethostname
  @title_from_cli = false
  @quote_file = nil
  @show_quote = true
  @config_path = DEFAULT_CONFIG_PATH
end

Class Method Details

.run(argv = ARGV) ⇒ Object



12
13
14
# File 'lib/motd_forge/cli.rb', line 12

def self.run(argv = ARGV)
  new(argv).run
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
# File 'lib/motd_forge/cli.rb', line 25

def run
  parse_options!
  load_config!

  quote = @show_quote ? Quotes.new(file: @quote_file).pick : nil
  puts Banner.new(title: @title, quote: quote).render
  0
end