class Bashly::Script::CatchAll
Public Class Methods
Source
# File lib/bashly/script/catch_all.rb, line 9 def from_config(config) options = case config when nil { enabled: false } when String { label: config } when Hash config.transform_keys(&:to_sym).slice(*option_keys) else {} end new(**options) end
Source
# File lib/bashly/script/catch_all.rb, line 25 def initialize(label: nil, help: nil, required: false, catch_help: false, enabled: true) @label = label @help = help @required = required @enabled = enabled @catch_help = catch_help end
Source
# File lib/bashly/script/catch_all.rb, line 5 def option_keys @option_keys ||= %i[label help required catch_help] end
Public Instance Methods
Source
# File lib/bashly/script/catch_all.rb, line 49 def catch_help? @catch_help end
Source
# File lib/bashly/script/catch_all.rb, line 37 def label enabled? ? "#{@label&.upcase}..." : nil end
Source
# File lib/bashly/script/catch_all.rb, line 53 def usage_string return nil unless enabled? required? ? "[--] #{label}" : "[--] [#{label}]" end