Class: Slideck::CLI Private

Inherits:
Object
  • Object
show all
Includes:
TTY::Option
Defined in:
lib/slideck/cli.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Responsible for parsing command line inputs

Instance Method Summary collapse

Constructor Details

#initialize(runner, output, error_output) ⇒ CLI

Create a CLI instance

Examples:

Slideck::CLI.new(runner, $stdout, $stderr)

Parameters:

  • runner (Slideck::Runner)

    the runner used to display slides

  • output (IO)

    the output stream

  • error_output (IO)

    the error output stream



113
114
115
116
117
# File 'lib/slideck/cli.rb', line 113

def initialize(runner, output, error_output)
  @runner = runner
  @output = output
  @error_output = error_output
end

Instance Method Details

#start(cmd_args, env) ⇒ void

This method returns an undefined value.

Start presenting slides deck

Examples:

cli.start(["slides.md"], {})

Parameters:

  • cmd_args (Array<String>)

    the command arguments

  • env (Hash{String => String})

    the environment variables

Raises:

  • (SystemExit)


134
135
136
137
138
139
140
141
142
143
144
# File 'lib/slideck/cli.rb', line 134

def start(cmd_args, env)
  parse(cmd_args, env)

  print_version || print_help || print_errors

  rescue_errors do
    @runner.run(params[:file],
                color: color(no_color_env?(cmd_args, env)),
                watch: params[:watch])
  end
end