Module: ShellOpts

Defined in:
lib/shellopts/program.rb,
lib/shellopts.rb,
lib/shellopts/ansi.rb,
lib/shellopts/args.rb,
lib/shellopts/dump.rb,
lib/shellopts/lexer.rb,
lib/shellopts/stack.rb,
lib/shellopts/token.rb,
lib/shellopts/parser.rb,
lib/shellopts/grammar.rb,
lib/shellopts/version.rb,
lib/shellopts/analyzer.rb,
lib/shellopts/renderer.rb,
lib/shellopts/formatter.rb,
lib/shellopts/interpreter.rb,
lib/shellopts/argument_type.rb

Overview

Option rendering

-a, --all                   # Only used in brief and doc formats (enum)
--all                       # Only used in usage (long)
-a                          # Only used in usage (short)

Option group rendering

-a, --all  -b, --beta       # Only used in brief formats (enum)
--all --beta                # Used in usage (long)
-a -b                       # Used in usage (short)

-a, --all                   # Only used in doc format (:multi)
-b, --beta

Command rendering

cmd --all --beta [cmd1|cmd2] ARG1 ARG2    # Single-line formats (:single)
cmd --all --beta [cmd1|cmd2] ARGS...     
cmd -a -b [cmd1|cmd2] ARG1 ARG2
cmd -a -b [cmd1|cmd2] ARGS...

cmd -a -b [cmd1|cmd2] ARG1 ARG2           # One line for each argument description (:enum)
cmd -a -b [cmd1|cmd2] ARG3 ARG4           # (used in the USAGE section)

cmd --all --beta                          # Multi-line formats (:multi)
    [cmd1|cmd2] ARG1 ARG2
cmd --all --beta
    <commands> ARGS

Defined Under Namespace

Modules: ErrorHandling, Grammar, Messages, Stack Classes: Analyzer, AnalyzerError, Ansi, Args, Command, CompilerError, Error, Failure, Formatter, InternalError, Interpreter, Lexer, LexerError, Line, Option, Parser, ParserError, Program, ShellOpts, ShellOptsError, Token

Constant Summary collapse

VERSION =
"2.0.4"

Class Method Summary collapse

Class Method Details

.instanceObject



311
# File 'lib/shellopts.rb', line 311

def self.instance() @instance or raise Error, "ShellOpts is not initialized" end

.instance=(instance) ⇒ Object



312
# File 'lib/shellopts.rb', line 312

def self.instance=(instance) @instance = instance end

.instance?Boolean

Returns:



310
# File 'lib/shellopts.rb', line 310

def self.instance?() !@instance.nil? end

.process(spec, argv, msgopts: false, **opts) ⇒ Object



304
305
306
307
# File 'lib/shellopts.rb', line 304

def self.process(spec, argv, msgopts: false, **opts)
  msgopts ||= Messages.is_included?
  ShellOpts.process(spec, argv, msgopts: msgopts, **opts)
end