Class: Slidict::Cli::Slides

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(output:, credentials: nil, client: nil, reauthenticate: nil) ⇒ Slides

Returns a new instance of Slides.



7
8
9
10
11
12
# File 'lib/slidict/cli/slides.rb', line 7

def initialize(output:, credentials: nil, client: nil, reauthenticate: nil)
  @output = output
  @credentials = credentials || External::SlidictIo::Credentials.new
  @client = client
  @reauthenticate = reauthenticate
end

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



29
30
31
32
# File 'lib/slidict/cli/slides.rb', line 29

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



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/slidict/cli/slides.rb', line 14

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
  1
end