mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Abstract conf parsing to class
This commit is contained in:
parent
9b176a7bd5
commit
c738b0c566
2 changed files with 16 additions and 12 deletions
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'commander'
|
require 'commander'
|
||||||
require 'yaml'
|
|
||||||
require 'vmfloaty/auth'
|
require 'vmfloaty/auth'
|
||||||
require 'vmfloaty/pooler'
|
require 'vmfloaty/pooler'
|
||||||
require 'vmfloaty/version'
|
require 'vmfloaty/version'
|
||||||
|
require 'vmfloaty/conf'
|
||||||
|
|
||||||
class Vmfloaty
|
class Vmfloaty
|
||||||
include Commander::Methods
|
include Commander::Methods
|
||||||
|
|
@ -14,7 +14,7 @@ class Vmfloaty
|
||||||
program :version, Version.get
|
program :version, Version.get
|
||||||
program :description, 'A CLI helper tool for Puppet Labs vmpooler to help you stay afloat'
|
program :description, 'A CLI helper tool for Puppet Labs vmpooler to help you stay afloat'
|
||||||
|
|
||||||
config = read_config
|
config = Conf.read_config
|
||||||
|
|
||||||
command :get do |c|
|
command :get do |c|
|
||||||
c.syntax = 'floaty get [hostname,...]'
|
c.syntax = 'floaty get [hostname,...]'
|
||||||
|
|
@ -235,14 +235,4 @@ class Vmfloaty
|
||||||
|
|
||||||
run!
|
run!
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_config
|
|
||||||
conf = {}
|
|
||||||
begin
|
|
||||||
conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml")
|
|
||||||
rescue
|
|
||||||
STDERR.puts "WARNING: There was no config file at #{Dir.home}/.vmfloaty.yml"
|
|
||||||
end
|
|
||||||
conf
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
14
lib/vmfloaty/conf.rb
Normal file
14
lib/vmfloaty/conf.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
class Conf
|
||||||
|
|
||||||
|
def self.read_config
|
||||||
|
conf = {}
|
||||||
|
begin
|
||||||
|
conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml")
|
||||||
|
rescue
|
||||||
|
STDERR.puts "WARNING: There was no config file at #{Dir.home}/.vmfloaty.yml"
|
||||||
|
end
|
||||||
|
conf
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue