Class: Snippit::CLI::Get

Inherits:
Object
  • Object
show all
Includes:
IO
Defined in:
lib/snippit/cli/get.rb

Overview

Snippit::CLI::Get gets a snippet's contents.

Instance Method Summary collapse

Methods included from IO

#definitions, #definitions_file, #delete_snippet, #filepath!, #read_snippet, #snippit_dir, #snippit_dir!, #write_definition, #write_snippet

Constructor Details

#initialize(slug) ⇒ Get

Returns a new instance of Get.



11
12
13
# File 'lib/snippit/cli/get.rb', line 11

def initialize(slug)
  @slug = slug
end

Instance Method Details

#startInteger

Starts the get subcommand.

Returns:

  • (Integer)

    the exit code



18
19
20
21
22
23
24
25
26
# File 'lib/snippit/cli/get.rb', line 18

def start
  unless definitions.key?(@slug)
    warn "Snippet '#{@slug}' does not exist."
    return 1
  end

  print read_snippet(@slug)
  0
end