Sha256: 01d866a13b5fec2c51b6ce978a4e8be2981fb6d92e808ceeb10d0133083f5375
Contents?: true
Size: 1.43 KB
Versions: 6
Compression:
Stored size: 1.43 KB
Contents
require_relative 'os_fetcher' require_relative 'options/parser' module Dirwatch class Options def self.from_args args parser = Parser.from_args args parser.parse! args new parser.action, parser.options.to_h end attr_reader :action, :options def initialize action, options @action = action.to_sym @options = send "#{@action}_options", options end def to_h @options end def method_missing m, *args, &block return @options[m] if @options && @options.key?(m) super end def respond_to_missing? m, include_private = false (@options && @options.key?(m)) || super end private def exit_options _options {} end def watch_options options { directory: options.fetch(:directory, './'), daemonize: options.fetch(:daemonize, false), once: options.fetch(:once, false), verbose: options.fetch(:verbose, false), } end def init_options options opts = { template: options.fetch(:template, nil), list: options.fetch(:list, false), operating_system: options.fetch(:operating_system, OsFetcher.fetch), verbose: options.fetch(:verbose, false), force: options.fetch(:force, false), } if opts[:list] opts.delete :template opts.delete :force end opts end end end
Version data entries
6 entries across 6 versions & 1 rubygems