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.15"

Class Method Summary collapse

Class Method Details

.error(subject = nil, message) ⇒ Object



335
336
337
338
339
# File 'lib/shellopts.rb', line 335

def self.error(subject = nil, message)
  instance.error(subject, message) if instance? # Never returns
  $stderr.puts "#{File.basename($PROGRAM_NAME)}: #{message}"
  exit 1
end

.failure(message) ⇒ Object



341
342
343
344
345
# File 'lib/shellopts.rb', line 341

def self.failure(message)
  instance.failure(message) if instance?
  $stderr.puts "#{File.basename($PROGRAM_NAME)}: #{message}"
  exit 1
end

.instanceObject



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

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

.instance=(instance) ⇒ Object



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

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

.instance?Boolean

Returns:

  • (Boolean)


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

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

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



324
325
326
327
# File 'lib/shellopts.rb', line 324

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

.shelloptsObject



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

def self.shellopts() instance end