Class: Retter::Command
- Inherits:
-
Thor
- Object
- Thor
- Retter::Command
- Includes:
- Stationery
- Defined in:
- lib/retter/command.rb
Instance Method Summary collapse
- #callback ⇒ Object
- #commit ⇒ Object
- #edit(identifier = options[:date] || options[:key]) ⇒ Object
- #gen ⇒ Object
- #home ⇒ Object
- #list ⇒ Object
- #new ⇒ Object
- #open ⇒ Object
- #preview(identifier = options[:date] || options[:key]) ⇒ Object
- #rebind ⇒ Object (also: #bind)
- #usage ⇒ Object
- #version ⇒ Object
Instance Method Details
#callback ⇒ Object
95 96 97 |
# File 'lib/retter/command.rb', line 95 def callback invoke_after [:after].intern end |
#commit ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/retter/command.rb', line 66 def commit Repository.open config.retter_home do |git| say git.add(config.retter_home), :green say git.commit_all('Retter commit'), :green end invoke_after :commit unless silent? end |
#edit(identifier = options[:date] || options[:key]) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/retter/command.rb', line 19 def edit(identifier = [:date] || [:key]) entry = entries.detect_by_string(identifier) system config.editor, entry.path invoke_after :edit unless silent? end |
#gen ⇒ Object
103 |
# File 'lib/retter/command.rb', line 103 def gen; end |
#home ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/retter/command.rb', line 85 def home Dir.chdir config.retter_home.to_path system config.shell say 'bye', :green end |
#list ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/retter/command.rb', line 76 def list entries.each_with_index do |entry, n| say "[e#{n}] #{entry.date}" say " #{entry.articles.map(&:title).join(', ')}" say end end |
#new ⇒ Object
100 |
# File 'lib/retter/command.rb', line 100 def new; end |
#open ⇒ Object
41 42 43 44 45 |
# File 'lib/retter/command.rb', line 41 def open index_page = Pages::Index.new Launchy.open index_page.path end |
#preview(identifier = options[:date] || options[:key]) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/retter/command.rb', line 31 def preview(identifier = [:date] || [:key]) preprint = Preprint.new entry = entries.detect_by_string(identifier) preprint.print entry Launchy.open preprint.path end |
#rebind ⇒ Object Also known as: bind
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/retter/command.rb', line 49 def rebind entries.commit_wip_entry! pages.bind! unless silent? invoke_after :bind invoke_after :rebind end end |
#usage ⇒ Object
106 107 108 |
# File 'lib/retter/command.rb', line 106 def usage say Command.usage, :green end |
#version ⇒ Object
111 112 113 |
# File 'lib/retter/command.rb', line 111 def version say "Retter version #{VERSION}" end |