# frozen_string_literal: false require 'optparse' require_relative 'version' module Propane # Utility class to handle the different commands that the 'propane' offers class Runner attr_reader :options, :argc, :filename def initialize @options = {} end # Start running a propane command from the passed-in arguments def self.execute runner = new runner.parse_options(ARGV) runner.execute! end # Dispatch central. def execute! show_help if options.empty? show_version if options[:version] create if options[:create] install(filename) if options[:install] end # Parse the command-line options. Keep it simple. def parse_options(args) opt_parser = OptionParser.new do |opts| # Set a banner, displayed at the top # of the help screen. opts.banner = 'Usage: propane [options] []' # Define the options, and what they do options[:version] = false opts.on('-v', '--version', 'Propane Version') do options[:version] = true end options[:install] = false message = '