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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/file_templater/options_handler.rb', line 3
def initialize(argv)
@nomodify = false
@template = nil
@binding = nil
@actions = []
parser = OptionParser.new do |o|
o.banner = "Usage: template [options] [binding arguments]"
o.separator ""
o.separator "Specific options:"
o.on("-t", "--template TEMPLATE",
"Load TEMPLATE to insert",
"into the current directory") do |t|
can_only_be_used_once @template, "-t"
@actions << [:template]
@template = t
end
o.on("-b", "--binding BINDING",
"Load BINDING as the binding",
"for the loaded template") do |b|
can_only_be_used_once @binding, "-b"
@binding = b
end
o.on("-a", "--add THING", Array,
"Add THING, a template or a binding,",
"to the template or binding directory") do |t|
@actions << [:add, t]
end
o.on("-r", "--remove THING", Array,
"Removes template or binding THING") do |tb|
@actions << [:remove, tb]
end
o.on("-l", "--list",
"Lists the templates and bindings",
"that are loaded") do
@actions << [:list]
end
o.on("-m", "--no-modify",
"Prevents modifying the template source",
"when loading") do
@nomodify = true
end
o.on("-c", "--copy THING", Array,
"Copies THING, a template or binding,",
"into current directory") do |tb|
@actions << [:copy, tb]
end
o.separator ""
o.separator "Common options:"
o.on_tail("-v", "--version", "Display the version") do
puts "File Templater (template) version " + VERSION
puts
puts "Copyright (C) 2015 Sam Craig"
puts "Licensed under the GNU General Public License version 3."
exit
end
o.on_tail("-h", "--help", "Show this message") do
puts o
exit
end
end
parser.parse!(argv)
@arguments = argv
end
|