41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/topicz/commands/note_command.rb', line 41
def execute
topic = find_exactly_one_topic(@filter, @strict)
path = File.join(topic.fullpath, Topicz::DIR_NOTES)
FileUtils.mkdir(path) unless Dir.exist? path
if @title
date = DateTime.now.strftime('%Y-%m-%d')
title = @title
filename = Zaru.sanitize! "#{date} #{title}.md"
else
date = DateTime.now.strftime('%Y-%m-%d %H%M')
title = 'Unnamed note'
filename = "#{date}.md"
end
path = File.join(path, filename)
unless File.exists? path
File.open(path, 'w') do | file |
file.puts("# #{topic.title} - #{title}")
end
end
@kernel.exec "#{editor} \"#{path}\""
end
|