Class: Retter::Command

Inherits:
Thor
  • Object
show all
Includes:
Stationery
Defined in:
lib/retter/command.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



95
96
97
# File 'lib/retter/command.rb', line 95

def callback
  invoke_after options[:after].intern
end

#commitObject



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 = options[:date] || options[:key])
  entry = entries.detect_by_string(identifier)

  system config.editor, entry.path

  invoke_after :edit unless silent?
end

#genObject



103
# File 'lib/retter/command.rb', line 103

def gen; end

#homeObject



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

#listObject



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

#newObject



100
# File 'lib/retter/command.rb', line 100

def new; end

#openObject



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 = options[:date] || options[:key])
  preprint = Preprint.new
  entry = entries.detect_by_string(identifier)

  preprint.print entry

  Launchy.open preprint.path
end

#rebindObject 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

#usageObject



106
107
108
# File 'lib/retter/command.rb', line 106

def usage
  say Command.usage, :green
end

#versionObject



111
112
113
# File 'lib/retter/command.rb', line 111

def version
  say "Retter version #{VERSION}"
end