Class: Heroku::Scalr::CLI
- Inherits:
-
Object
- Object
- Heroku::Scalr::CLI
- Defined in:
- lib/heroku/scalr/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #parser ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/heroku/scalr/cli.rb', line 12 def initialize(argv) super() @config_path = "./config.rb" @options = { log_level: ::Logger::INFO } parser.parse!(argv) unless File.file?(@config_path) puts parser exit end end |
Class Method Details
.run!(argv = ARGV) ⇒ Object
8 9 10 |
# File 'lib/heroku/scalr/cli.rb', line 8 def self.run!(argv = ARGV) new(argv).run! end |
Instance Method Details
#parser ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/heroku/scalr/cli.rb', line 30 def parser @parser ||= OptionParser.new do |o| o. = "Usage: heroku-scalr [options]" o.separator "" o.on("-C", "--config PATH", "Configuration file path. Default: ./config.rb") do |path| @config_path = path end o.on("-l", "--log PATH", "Custom log file path. Default: STDOUT") do |path| @options.update log_file: path end o.on("-v", "--verbose", "Enable verbose logging.") do @options.update log_level: ::Logger::DEBUG end o.separator "" o.on_tail("-h", "--help", "Show this message") do puts o exit end end end |