Class: Snippit::CLI::Get
Overview
Snippit::CLI::Get gets a snippet's contents.
Instance Method Summary collapse
-
#initialize(slug) ⇒ Get
constructor
A new instance of Get.
-
#start ⇒ Integer
Starts the get subcommand.
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
#start ⇒ Integer
Starts the get subcommand.
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 |