Class: Pandocomatic::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/pandocomatic/cli.rb

Overview

Command line options parser for pandocomatic using optimist.

Class Method Summary collapse

Class Method Details

.parse!(args) ⇒ Configuration

Parse the arguments, returns a triplet with the global options, an optional subcommand, and the (optional) options for that subcommand.

As a side effect, this method will create and install a logger for Pandocomatic::LOG.

the command-line options.

Parameters:

  • args (String, Array)

    A command-line invocation string or a list of strings like ARGV

Returns:

  • (Configuration)

    The configuration for running pandocomatic given



44
45
46
47
48
49
50
51
52
# File 'lib/pandocomatic/cli.rb', line 44

def self.parse!(args)
  args = args.split if args.is_a? String

  begin
    parse_options args || Configuration.new({ help: true, help_given: true })
  rescue Optimist::CommandlineError => e
    raise CLIError.new(:problematic_invocation, e, args)
  end
end