class Rbnotes::Commands::Export
Writes out a given note into a specified file. The file will be created in the current working directory unless an absolute path is specified as a filename.
When no argument was passed, would try to read a timestamp string from the standard input.
Public Instance Methods
execute([a String as timestring], Rbnotes::Conf or Hash) → nil
click to toggle source
# File lib/rbnotes/commands/export.rb, line 23 def execute(args, conf) stamp = Rbnotes.utils.read_timestamp(args) repo = Textrepo.init(conf) begin content = repo.read(stamp) rescue Textrepo::MissingTimestampError => _ raise MissingTimestampError, stamp end pathname = Pathname.new(args.shift || "#{stamp}.md") pathname.parent.mkpath pathname.open("w"){ |f| f.puts content } puts "Export a note [%s] into a file [%s]" % [stamp, pathname] end