Class: Snippit::CLI::Delete

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

Overview

Snippit::CLI::Delete deletes a snippet.

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) ⇒ Delete

Returns a new instance of Delete.



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

def initialize(slug)
  @slug = slug
end

Instance Method Details

#startInteger

Starts the delete subcommand.

Returns:

  • (Integer)

    the exit code



18
19
20
21
22
23
# File 'lib/snippit/cli/delete.rb', line 18

def start
  return 1 unless definitions.key?(@slug)

  delete_snippet(@slug)
  0
end