command :write do |c| c.syntax = 'brief write PUBLISHER [options]' c.option '--file FILE', 'Specify a file to read from. Otherwise we use $EDITOR' c.action do |args, options| path = case when options.file Pathname(options.file) when (Pathname(args.last).exist? rescue false) Pathname(args.pop) end publisher = Brief::Publisher.find(args) content = ask_editor(publisher.sample) if content == publisher.sample say "Ignoring editor input, same as sample" else document = Brief::Document.new(content) document.publish(publisher) end end end