Sha256: 6f75c2dfd8f21f0cc5411a30844de99bf0ae3c07edbe37397a77c5a81e889618
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
require 'yaml' module WorkingMan class CLI class Config # Internal: Checks for a configuration file. If one is not found, message # is printed to the console and system exits with status code "1" # # Examples: # # check_config(config_path) # # Returns true if everything passes def self.check_config(config_path) if File.exists?(config_path) check_config_format(config_path) return true else puts "No configuration found. Please configure which apps to start in #{config_path}" exit 1 end end # Internal: Checks the format of the configuration file. If the configuration # is blank, exits with status "2". If there are no apps, exits with status "3" # If there are no URLs, prints a warning but continues with execution. # # Examples: # # check_config_format(config_path) # # Returns true if everything passes def self.check_config_format(config_path) $config = YAML::load(File.open(config_path)) if !$config p "Nothing in configuration. Exiting..." exit 2 elsif !$config['apps'] p "No applications in configuration. Exiting..." exit 2 elsif !$config['urls'] p "WARN: No URLs in configuration" return true end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
working_man-1.2.0 | lib/working_man/cli/config.rb |
working_man-1.1.0 | lib/working_man/cli/config.rb |
working_man-1.0.0 | lib/working_man/cli/config.rb |