sorbet/rbi/gems/slop@3.6.0.rbi
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `slop` gem.
# Please instead update this file by running `bin/tapioca gem slop`.
# source://slop-3.6.0/lib/slop/option.rb:1
class Slop
include ::Enumerable
# Create a new instance of Slop and optionally build options via a block.
#
# config - A Hash of configuration options.
# block - An optional block used to specify options.
#
# @return [Slop] a new instance of Slop
#
# source://slop-3.6.0/lib/slop.rb:128
def initialize(config = T.unsafe(nil), &block); end
# Fetch an options argument value.
#
# key - The Symbol or String option short or long flag.
#
# Returns the Object value for this option, or nil.
#
# source://slop-3.6.0/lib/slop.rb:293
def [](key); end
# Add a callback.
#
# label - The Symbol identifier to attach this callback.
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop.rb:413
def add_callback(label, &block); end
# Get or set the banner.
#
# banner - The String to set the banner.
#
# Returns the banner String.
#
# source://slop-3.6.0/lib/slop.rb:171
def banner(banner = T.unsafe(nil)); end
# Set the banner.
#
# banner - The String to set the banner.
#
# source://slop-3.6.0/lib/slop.rb:162
def banner=(banner); end
# Add a new command.
#
# command - The Symbol or String used to identify this command.
# options - A Hash of configuration options (see Slop::new)
#
# Returns a new instance of Slop mapped to this command.
#
# source://slop-3.6.0/lib/slop.rb:199
def command(command, options = T.unsafe(nil), &block); end
# The Hash of sub-commands for this Slop instance.
#
# source://slop-3.6.0/lib/slop.rb:122
def commands; end
# The Hash of configuration options for this Slop instance.
#
# source://slop-3.6.0/lib/slop.rb:116
def config; end
# Get or set the description (used for commands).
#
# desc - The String to set the description.
#
# Returns the description String.
#
# source://slop-3.6.0/lib/slop.rb:188
def description(desc = T.unsafe(nil)); end
# Set the description (used for commands).
#
# desc - The String to set the description.
#
# source://slop-3.6.0/lib/slop.rb:179
def description=(desc); end
# Enumerable interface. Yields each Slop::Option.
#
# source://slop-3.6.0/lib/slop.rb:312
def each(&block); end
# Fetch a Slop object associated with this command.
#
# command - The String or Symbol name of the command.
#
# Examples:
#
# opts.command :foo do
# on :v, :verbose, 'Enable verbose mode'
# end
#
# # ruby run.rb foo -v
# opts.fetch_command(:foo).verbose? #=> true
#
# source://slop-3.6.0/lib/slop.rb:404
def fetch_command(command); end
# Fetch a Slop::Option object.
#
# key - The Symbol or String option key.
#
# Examples:
#
# opts.on(:foo, 'Something fooey', :argument => :optional)
# opt = opts.fetch_option(:foo)
# opt.class #=> Slop::Option
# opt.accepts_optional_argument? #=> true
#
# Returns an Option or nil if none were found.
#
# source://slop-3.6.0/lib/slop.rb:388
def fetch_option(key); end
# Fetch an options argument value.
#
# key - The Symbol or String option short or long flag.
#
# Returns the Object value for this option, or nil.
#
# source://slop-3.6.0/lib/slop.rb:293
def get(key); end
# Print a handy Slop help string.
#
# Returns the banner followed by available option help strings.
#
# source://slop-3.6.0/lib/slop.rb:431
def help; end
# Fetch a list of options which were missing from the parsed list.
#
# Examples:
#
# opts = Slop.new do
# on :n, :name=
# on :p, :password=
# end
#
# opts.parse %w[ --name Lee ]
# opts.missing #=> ['password']
#
# Returns an Array of Strings representing missing options.
#
# source://slop-3.6.0/lib/slop.rb:372
def missing; end
# Add an Option.
#
# objects - An Array with an optional Hash as the last element.
#
# Examples:
#
# on '-u', '--username=', 'Your username'
# on :v, :verbose, 'Enable verbose mode'
#
# Returns the created instance of Slop::Option.
#
# source://slop-3.6.0/lib/slop.rb:276
def on(*objects, &block); end
# Add an Option.
#
# objects - An Array with an optional Hash as the last element.
#
# Examples:
#
# on '-u', '--username=', 'Your username'
# on :v, :verbose, 'Enable verbose mode'
#
# Returns the created instance of Slop::Option.
#
# source://slop-3.6.0/lib/slop.rb:276
def opt(*objects, &block); end
# Add an Option.
#
# objects - An Array with an optional Hash as the last element.
#
# Examples:
#
# on '-u', '--username=', 'Your username'
# on :v, :verbose, 'Enable verbose mode'
#
# Returns the created instance of Slop::Option.
#
# source://slop-3.6.0/lib/slop.rb:276
def option(*objects, &block); end
# The Array of Slop::Option objects tied to this Slop instance.
#
# source://slop-3.6.0/lib/slop.rb:119
def options; end
# Parse a list of items, executing and gathering options along the way.
#
# items - The Array of items to extract options from (default: ARGV).
# block - An optional block which when used will yield non options.
#
# Returns an Array of original items.
#
# source://slop-3.6.0/lib/slop.rb:210
def parse(items = T.unsafe(nil), &block); end
# Parse a list of items, executing and gathering options along the way.
# unlike parse() this method will remove any options and option arguments
# from the original Array.
#
# items - The Array of items to extract options from (default: ARGV).
# block - An optional block which when used will yield non options.
#
# Returns an Array of original items with options removed.
#
# source://slop-3.6.0/lib/slop.rb:223
def parse!(items = T.unsafe(nil), &block); end
# Check for an options presence.
#
# Examples:
#
# opts.parse %w( --foo )
# opts.present?(:foo) #=> true
# opts.present?(:bar) #=> false
#
# Returns true if all of the keys are present in the parsed arguments.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop.rb:348
def present?(*keys); end
# Specify code to be executed when these options are parsed.
#
# callable - An object responding to a call method.
#
# yields - The instance of Slop parsing these options
# An Array of unparsed arguments
#
# Example:
#
# Slop.parse do
# on :v, :verbose
#
# run do |opts, args|
# puts "Arguments: #{args.inspect}" if opts.verbose?
# end
# end
#
# source://slop-3.6.0/lib/slop.rb:332
def run(callable = T.unsafe(nil), &block); end
# Add string separators between options.
#
# text - The String text to print.
#
# source://slop-3.6.0/lib/slop.rb:420
def separator(text); end
# Is strict mode enabled?
#
# Returns true if strict mode is enabled, false otherwise.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop.rb:155
def strict?; end
# Returns a new Hash with option flags as keys and option values as values.
#
# include_commands - If true, merge options from all sub-commands.
#
# source://slop-3.6.0/lib/slop.rb:302
def to_h(include_commands = T.unsafe(nil)); end
# Returns a new Hash with option flags as keys and option values as values.
#
# include_commands - If true, merge options from all sub-commands.
#
# source://slop-3.6.0/lib/slop.rb:302
def to_hash(include_commands = T.unsafe(nil)); end
# Print a handy Slop help string.
#
# Returns the banner followed by available option help strings.
#
# source://slop-3.6.0/lib/slop.rb:431
def to_s; end
private
# Autocreate an option on the fly. See the :autocreate Slop config option.
#
# items - The Array of items we're parsing.
# index - The current Integer index for the item we're processing.
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop.rb:615
def autocreate(items, index); end
# Build an option from a list of objects.
#
# objects - An Array of objects used to build this option.
#
# Returns a new instance of Slop::Option.
#
# source://slop-3.6.0/lib/slop.rb:631
def build_option(objects, &block); end
# Remove any leading -- characters from a string.
#
# object - The Object we want to cast to a String and clean.
#
# Returns the newly cleaned String with leading -- characters removed.
#
# source://slop-3.6.0/lib/slop.rb:675
def clean(object); end
# source://slop-3.6.0/lib/slop.rb:679
def commands_to_help; end
# Execute a `-abc` type option where a, b and c are all options. This
# method is only executed if the multiple_switches argument is true.
#
# option - The first Option object.
# argument - The argument to this option. (Split into multiple Options).
# items - The Array of items currently being parsed.
# index - The index of the current item being processed.
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop.rb:570
def execute_multiple_switches(option, argument, items, index); end
# Execute an option, firing off callbacks and assigning arguments.
#
# option - The Slop::Option object found by #process_item.
# argument - The argument Object to assign to this option.
# index - The current Integer index of the object we're processing.
# item - The optional String item we're processing.
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop.rb:537
def execute_option(option, argument, index, item = T.unsafe(nil)); end
# Extract the long flag from an item.
#
# objects - The Array of objects passed from #build_option.
# config - The Hash of configuration options built in #build_option.
#
# source://slop-3.6.0/lib/slop.rb:660
def extract_long_flag(objects, config); end
# Extract an option from a flag.
#
# flag - The flag key used to extract an option.
#
# Returns an Array of [option, argument].
#
# source://slop-3.6.0/lib/slop.rb:593
def extract_option(flag); end
# source://slop-3.6.0/lib/slop.rb:647
def extract_short_flag(objects, config); end
# Convenience method for present?(:option).
#
# Examples:
#
# opts.parse %( --verbose )
# opts.verbose? #=> true
# opts.other? #=> false
#
# Returns true if this option is present. If this method does not end
# with a ? character it will instead call super().
#
# source://slop-3.6.0/lib/slop.rb:473
def method_missing(method, *args, &block); end
# Process a list item, figure out if it's an option, execute any
# callbacks, assign any option arguments, and do some sanity checks.
#
# items - The Array of items to process.
# index - The current Integer index of the item we want to process.
# block - An optional block which when passed will yield non options.
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop.rb:491
def process_item(items, index, &block); end
# Override this method so we can check if an option? method exists.
#
# Returns true if this option key exists in our list of options.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop.rb:355
def respond_to_missing?(method_name, include_private = T.unsafe(nil)); end
class << self
# Build a Slop object from a option specification.
#
# This allows you to design your options via a simple String rather
# than programatically. Do note though that with this method, you're
# unable to pass any advanced options to the on() method when creating
# options.
#
# string - The optspec String
# config - A Hash of configuration options to pass to Slop.new
#
# Examples:
#
# opts = Slop.optspec(<<-SPEC)
# ruby foo.rb [options]
# ---
# n,name= Your name
# a,age= Your age
# A,auth Sign in with auth
# p,passcode= Your secret pass code
# SPEC
#
# opts.fetch_option(:name).description #=> "Your name"
#
# Returns a new instance of Slop.
#
# source://slop-3.6.0/lib/slop.rb:93
def optspec(string, config = T.unsafe(nil)); end
# items - The Array of items to extract options from (default: ARGV).
# config - The Hash of configuration options to send to Slop.new().
# block - An optional block used to add options.
#
# Examples:
#
# Slop.parse(ARGV, :help => true) do
# on '-n', '--name', 'Your username', :argument => true
# end
#
# Returns a new instance of Slop.
#
# source://slop-3.6.0/lib/slop.rb:53
def parse(items = T.unsafe(nil), config = T.unsafe(nil), &block); end
# items - The Array of items to extract options from (default: ARGV).
# config - The Hash of configuration options to send to Slop.new().
# block - An optional block used to add options.
#
# Returns a new instance of Slop.
#
# source://slop-3.6.0/lib/slop.rb:62
def parse!(items = T.unsafe(nil), config = T.unsafe(nil), &block); end
end
end
# source://slop-3.6.0/lib/slop/commands.rb:2
class Slop::Commands
include ::Enumerable
# Create a new instance of Slop::Commands and optionally build
# Slop instances via a block. Any configuration options used in
# this method will be the default configuration options sent to
# each Slop object created.
#
# config - An optional configuration Hash.
# block - Optional block used to define commands.
#
# Examples:
#
# commands = Slop::Commands.new do
# on :new do
# on '-o', '--outdir=', 'The output directory'
# on '-v', '--verbose', 'Enable verbose mode'
# end
#
# on :generate do
# on '--assets', 'Generate assets', :default => true
# end
#
# global do
# on '-D', '--debug', 'Enable debug mode', :default => false
# end
# end
#
# commands[:new].class #=> Slop
# commands.parse
#
# @return [Commands] a new instance of Commands
#
# source://slop-3.6.0/lib/slop/commands.rb:36
def initialize(config = T.unsafe(nil), &block); end
# Fetch the instance of Slop tied to a command.
#
# key - The String or Symbol key used to locate this command.
#
# Returns the Slop instance if this key is found, nil otherwise.
#
# source://slop-3.6.0/lib/slop/commands.rb:97
def [](key); end
# Returns the value of attribute arguments.
#
# source://slop-3.6.0/lib/slop/commands.rb:5
def arguments; end
# Optionally set the banner for this command help output.
#
# banner - The String text to set the banner.
#
# Returns the String banner if one is set.
#
# source://slop-3.6.0/lib/slop/commands.rb:56
def banner(banner = T.unsafe(nil)); end
# Sets the attribute banner
#
# @param value the value to set the attribute banner to.
#
# source://slop-3.6.0/lib/slop/commands.rb:6
def banner=(_arg0); end
# Returns the value of attribute commands.
#
# source://slop-3.6.0/lib/slop/commands.rb:5
def commands; end
# Returns the value of attribute config.
#
# source://slop-3.6.0/lib/slop/commands.rb:5
def config; end
# Add a Slop instance used when no other commands exist.
#
# config - A Hash of configuration options to pass to Slop.
# block - An optional block used to pass options to Slop.
#
# Returns the newly created Slop instance mapped to default.
#
# source://slop-3.6.0/lib/slop/commands.rb:78
def default(config = T.unsafe(nil), &block); end
# Enumerable interface.
#
# source://slop-3.6.0/lib/slop/commands.rb:116
def each(&block); end
# Fetch the instance of Slop tied to a command.
#
# key - The String or Symbol key used to locate this command.
#
# Returns the Slop instance if this key is found, nil otherwise.
#
# source://slop-3.6.0/lib/slop/commands.rb:97
def get(key); end
# Add a global Slop instance.
#
# config - A Hash of configuration options to pass to Slop.
# block - An optional block used to pass options to Slop.
#
# Returns the newly created Slop instance mapped to global.
#
# source://slop-3.6.0/lib/slop/commands.rb:88
def global(config = T.unsafe(nil), &block); end
# Returns the help String.
#
# source://slop-3.6.0/lib/slop/commands.rb:160
def help; end
# Returns the inspection String.
#
# source://slop-3.6.0/lib/slop/commands.rb:176
def inspect; end
# Add a Slop instance for a specific command.
#
# command - A String or Symbol key used to identify this command.
# config - A Hash of configuration options to pass to Slop.
# block - An optional block used to pass options to Slop.
#
# Returns the newly created Slop instance mapped to command.
#
# source://slop-3.6.0/lib/slop/commands.rb:68
def on(command, config = T.unsafe(nil), &block); end
# Parse a list of items.
#
# items - The Array of items to parse.
#
# Returns the original Array of items.
#
# source://slop-3.6.0/lib/slop/commands.rb:125
def parse(items = T.unsafe(nil)); end
# Parse a list of items, removing any options or option arguments found.
#
# items - The Array of items to parse.
#
# Returns the original Array of items with options removed.
#
# source://slop-3.6.0/lib/slop/commands.rb:135
def parse!(items = T.unsafe(nil)); end
# Check for a command presence.
#
# Examples:
#
# cmds.parse %w( foo )
# cmds.present?(:foo) #=> true
# cmds.present?(:bar) #=> false
#
# Returns true if the given key is present in the parsed arguments.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop/commands.rb:111
def present?(key); end
# Returns a nested Hash with Slop options and values. See Slop#to_hash.
#
# source://slop-3.6.0/lib/slop/commands.rb:155
def to_hash; end
# Returns the help String.
#
# source://slop-3.6.0/lib/slop/commands.rb:160
def to_s; end
private
# Returns nothing.
#
# source://slop-3.6.0/lib/slop/commands.rb:183
def execute_arguments!(items); end
# Returns nothing.
#
# source://slop-3.6.0/lib/slop/commands.rb:189
def execute_global_opts!(items); end
end
# Returns a default Hash of configuration options this Slop instance uses.
#
# source://slop-3.6.0/lib/slop.rb:28
Slop::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
# The main Error class, all Exception classes inherit from this class.
#
# source://slop-3.6.0/lib/slop.rb:10
class Slop::Error < ::StandardError; end
# Raised when an argument does not match its intended match constraint.
#
# source://slop-3.6.0/lib/slop.rb:19
class Slop::InvalidArgumentError < ::Slop::Error; end
# Raised when an invalid command is found and the strict flag is enabled.
#
# source://slop-3.6.0/lib/slop.rb:25
class Slop::InvalidCommandError < ::Slop::Error; end
# Raised when an invalid option is found and the strict flag is enabled.
#
# source://slop-3.6.0/lib/slop.rb:22
class Slop::InvalidOptionError < ::Slop::Error; end
# Raised when an option argument is expected but none are given.
#
# source://slop-3.6.0/lib/slop.rb:13
class Slop::MissingArgumentError < ::Slop::Error; end
# Raised when an option is expected/required but not present.
#
# source://slop-3.6.0/lib/slop.rb:16
class Slop::MissingOptionError < ::Slop::Error; end
# source://slop-3.6.0/lib/slop/option.rb:2
class Slop::Option
# Incapsulate internal option information, mainly used to store
# option specific configuration data, most of the meat of this
# class is found in the #value method.
#
# slop - The instance of Slop tied to this Option.
# short - The String or Symbol short flag.
# long - The String or Symbol long flag.
# description - The String description text.
# config - A Hash of configuration options.
# block - An optional block used as a callback.
#
# @return [Option] a new instance of Option
#
# source://slop-3.6.0/lib/slop/option.rb:33
def initialize(slop, short, long, description, config = T.unsafe(nil), &block); end
# Returns true if this option accepts an optional argument.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop/option.rb:71
def accepts_optional_argument?; end
# Returns the value of attribute argument_in_value.
#
# source://slop-3.6.0/lib/slop/option.rb:21
def argument_in_value; end
# Sets the attribute argument_in_value
#
# @param value the value to set the attribute argument_in_value to.
#
# source://slop-3.6.0/lib/slop/option.rb:21
def argument_in_value=(_arg0); end
# Call this options callback if one exists, and it responds to call().
#
# Returns nothing.
#
# source://slop-3.6.0/lib/slop/option.rb:83
def call(*objects); end
# Returns the value of attribute config.
#
# source://slop-3.6.0/lib/slop/option.rb:20
def config; end
# Returns the value of attribute count.
#
# source://slop-3.6.0/lib/slop/option.rb:21
def count; end
# Sets the attribute count
#
# @param value the value to set the attribute count to.
#
# source://slop-3.6.0/lib/slop/option.rb:21
def count=(_arg0); end
# Returns the value of attribute description.
#
# source://slop-3.6.0/lib/slop/option.rb:20
def description; end
# Returns true if this option expects an argument.
#
# @return [Boolean]
#
# source://slop-3.6.0/lib/slop/option.rb:66
def expects_argument?; end
# Returns the help String for this option.
#
# source://slop-3.6.0/lib/slop/option.rb:127
def help; end
# Returns the String inspection text.
#
# source://slop-3.6.0/lib/slop/option.rb:151
def inspect; end
# Returns the String flag of this option. Preferring the long flag.
#
# source://slop-3.6.0/lib/slop/option.rb:76
def key; end
# Returns the value of attribute long.
#
# source://slop-3.6.0/lib/slop/option.rb:20
def long; end
# Returns the value of attribute short.
#
# source://slop-3.6.0/lib/slop/option.rb:20
def short; end
# Returns the help String for this option.
#
# source://slop-3.6.0/lib/slop/option.rb:127
def to_s; end
# Returns the value of attribute types.
#
# source://slop-3.6.0/lib/slop/option.rb:20
def types; end
# Fetch the argument value for this option.
#
# Returns the Object once any type conversions have taken place.
#
# source://slop-3.6.0/lib/slop/option.rb:107
def value; end
# Set the new argument value for this option.
#
# We use this setter method to handle concatenating lists. That is,
# when an array type is specified and used more than once, values from
# both options will be grouped together and flattened into a single array.
#
# source://slop-3.6.0/lib/slop/option.rb:92
def value=(new_value); end
private
# Convert an object to a Float if possible.
#
# value - The Object we want to convert to a float.
#
# Returns the Float value if possible to convert, else a zero.
#
# source://slop-3.6.0/lib/slop/option.rb:181
def value_to_float(value); end
# Convert an object to an Integer if possible.
#
# value - The Object we want to convert to an integer.
#
# Returns the Integer value if possible to convert, else a zero.
#
# source://slop-3.6.0/lib/slop/option.rb:164
def value_to_integer(value); end
# Convert an object to a Range if possible.
#
# value - The Object we want to convert to a range.
#
# Returns the Range value if one could be found, else the original object.
#
# source://slop-3.6.0/lib/slop/option.rb:198
def value_to_range(value); end
end
# The default Hash of configuration options this class uses.
#
# source://slop-3.6.0/lib/slop/option.rb:5
Slop::Option::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
# source://slop-3.6.0/lib/slop.rb:7
Slop::VERSION = T.let(T.unsafe(nil), String)