5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/models/console_app.rb', line 5
def run
arg = ARGV[0]
options = OptionParser.new do |opts|
opts.banner = 'Usage: notes [options]'
opts.separator('')
opts.separator('Options:')
opts.separator(' [FILE-GLOB] Open the first file that matches FILE-GLOB if supplied')
opts.on('-f', '--find FILE-GLOB', 'Find notes that fuzzily match FILE-GLOB') do |glob|
puts(find(glob))
exit(0)
end
opts.on('-l', '--list [PATH]', 'List all notes', ' (list notes under PATH if supplied)') do |path|
list(path)
exit(0)
end
opts.on('-n', '--new PATH', 'Create new note at PATH') do |path|
new_note(path)
open_notes(path)
exit(0)
end
opts.on('-s', '--search REGEX', 'Search within notes') do |regex|
search(regex)
exit(0)
end
opts.separator('')
opts.on('-h', '--help', 'Show this message') do
puts(opts)
exit(0)
end
opts.on('-v', '--version', 'Show version') do
puts(version)
exit(0)
end
opts.separator('')
opts.separator("Preferences are loaded from #{Preferences.prefs_file} and should look like:")
opts.separator(Preferences.defaults_yaml)
opts.separator('')
opts.separator("Documentation at https://github.com/fonsecapeter/peter-notes or man peter-notes")
end
begin
options.parse!
rescue OptionParser::InvalidOption
puts(options)
exit(1)
end
on_run(arg)
end
|