Class: Retter::Command
- Inherits:
-
Thor
- Object
- Thor
- Retter::Command
show all
- Includes:
- Site
- Defined in:
- lib/retter/command.rb
Instance Method Summary
collapse
Methods included from Site
#config, #entries, #load, #reset!
#configurable, #define_configurable_method, #define_instance_shortcut_method
Instance Method Details
#callback ⇒ Object
101
102
103
|
# File 'lib/retter/command.rb', line 101
def callback
invoke_after options[:after].intern
end
|
#clean ⇒ Object
84
85
86
87
88
|
# File 'lib/retter/command.rb', line 84
def clean
return unless config.cache.respond_to?(:clear)
config.cache.clear
end
|
#commit ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/retter/command.rb', line 65
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
end
|
#edit(identifier = options[:date] || options[:key]) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/retter/command.rb', line 20
def edit(identifier = options[:date] || options[:key])
entry = entries.detect_by_string(identifier)
system config.editor, entry.path.to_path
invoke_after :edit
end
|
#home ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/retter/command.rb', line 91
def home
Dir.chdir config.retter_home.to_path
system config.shell
say 'bye', :green
end
|
#list ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/retter/command.rb', line 75
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
106
|
# File 'lib/retter/command.rb', line 106
def new; end
|
#open ⇒ Object
42
43
44
45
46
|
# File 'lib/retter/command.rb', line 42
def open
index_page = Page::Index.new
Launchy.open index_page.path.to_path
end
|
#preview(identifier = options[:date] || options[:key]) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/retter/command.rb', line 32
def preview(identifier = options[:date] || options[:key])
preprint = Preprint.new
entry = entries.detect_by_string(identifier)
preprint.bind entry
Launchy.open preprint.path.to_path
end
|
#rebind ⇒ Object
Also known as:
bind
50
51
52
53
54
55
56
57
|
# File 'lib/retter/command.rb', line 50
def rebind
entries.commit_wip_entry!
Binder.new(entries).bind!
invoke_after :bind
invoke_after :rebind
end
|
#usage ⇒ Object
109
110
111
|
# File 'lib/retter/command.rb', line 109
def usage
say Command.usage, :green
end
|
#version ⇒ Object
114
115
116
|
# File 'lib/retter/command.rb', line 114
def version
say "Retter version #{VERSION}"
end
|