Class: Cue::Command::Add

Inherits:
Base
  • Object
show all
Defined in:
lib/cue/command/add.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#find_item, #find_key, #parser

Constructor Details

#initialize(args) ⇒ Add

Returns a new instance of Add.



7
8
9
10
11
12
13
14
15
# File 'lib/cue/command/add.rb', line 7

def initialize(args)
  super(args)
  
  if @args.size == 1
    @content = @args.first
  else
    @content = Utils::Editor.new.read
  end
end

Instance Method Details

#executeObject



17
18
19
20
# File 'lib/cue/command/add.rb', line 17

def execute
  item = Cue::Item.new(@content)
  item.save(options.store)
end

#nargsObject



22
23
24
# File 'lib/cue/command/add.rb', line 22

def nargs
  (0..1)
end