Class: Slidict::Cli::Slides

Inherits:
Object
  • Object
show all
Includes:
Options
Defined in:
lib/slidict/cli/slides.rb

Overview

Implements the slidict slides <list|show|create|edit> subcommands.

Constant Summary

Constants included from Options

Options::FAILURE, Options::MISSING, Options::SUCCESS

Instance Method Summary collapse

Methods included from Options

included

Instance Method Details

#publish(body:, id: nil, title: nil, body_format: nil, visibility: nil) ⇒ Object

Creates or edits a draft directly, bypassing argv parsing (and its "looks like a flag" checks, which would reject body text such as YAML frontmatter that happens to start with "-").



46
47
48
49
# File 'lib/slidict/cli/slides.rb', line 46

def publish(body:, id: nil, title: nil, body_format: nil, visibility: nil)
  options = { id: id, title: title, body: body, body_format: body_format, visibility: visibility }
  id ? edit(options) : create(options)
end

#run(argv) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/slidict/cli/slides.rb', line 31

def run(argv)
  options = parse(argv)
  return print_help if options[:help] || options[:subcommand].nil?

  send(options[:subcommand], options)
rescue ArgumentError => e
  @output.puts "Error: #{e.message}"
  @output.puts
  print_help
  FAILURE
end