-
Notifications
You must be signed in to change notification settings - Fork 7
/
commands.rb
49 lines (40 loc) · 888 Bytes
/
commands.rb
1
2
3
4
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
# encoding: utf-8
include GLI::App
version Glyph::VERSION
program_desc "A rapid document authoring framework"
d "Enable debugging"
switch [:d, :debug]
d "Display documentation"
switch [:h, :help]
commands_from Glyph::LIB/"commands"
Glyph.run 'load:tasks'
Glyph.run 'load:commands'
pre do |global,command,options,args|
# Pre logic here
# Return true to proceed; false to abort and not call the
# chosen command
if global[:d] then
Glyph.debug_mode = true
end
true
end
post do |global,command,options,args|
# Post logic here
end
on_error do |exception|
raise if Glyph.library?
if exception.is_a? Glyph::MacroError then
exception.display
else
Glyph.warning exception.message
if Glyph.debug? then
puts "\n"+"-"*20+"[ Backtrace: ]"+"-"*20
puts "Backtrace:"
exception.backtrace.each do |b|
puts b
end
Glyph.debug_mode = false
end
end
false
end