Class: Memo::Cli::Command::Edit

Inherits:
Object
  • Object
show all
Defined in:
lib/memo/cli/command/edit.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, os: Memo::OS.new) ⇒ Edit

Returns a new instance of Edit.



5
6
7
8
9
10
11
12
# File 'lib/memo/cli/command/edit.rb', line 5

def initialize(
  options,
  os: Memo::OS.new
)
  @options = options
  @os = os
  @config = Memo::Config.new
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
# File 'lib/memo/cli/command/edit.rb', line 14

def call
  filename = @options[0]
  namespace = @options.namespace

  file = Memo::File.new(filename, namespace)

  @os.exec "mkdir -p #{@config.root}/#{file.dir}"
  @os.exec "#{@config.editor} #{@config.root}/#{file.fullpath}"
end