ytools 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/VERSION +1 -1
- data/lib/ytools/basecli.rb +1 -2
- data/lib/ytools/path/cli.rb +2 -0
- data/lib/ytools/templates/cli.rb +21 -2
- data/lib/ytools/templates/executor.rb +1 -1
- metadata +3 -3
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/ytools/basecli.rb
CHANGED
@@ -23,9 +23,8 @@ module YTools
|
|
23
23
|
protected
|
24
24
|
def tail(command)
|
25
25
|
command.alter do
|
26
|
-
string :literal, "Evaluate a literal string in addition to any file paths."
|
27
26
|
boolean :strict, "Checks to make sure all of the YAML files exist before proceeding."
|
28
|
-
|
27
|
+
boolean_ :examples, "Show some examples on how to use the path syntax." do
|
29
28
|
validate do |show, options|
|
30
29
|
if show
|
31
30
|
YTools::Utils.print_example(File.join(File.dirname(__FILE__), command.name.to_s.gsub(/^y/, '')))
|
data/lib/ytools/path/cli.rb
CHANGED
data/lib/ytools/templates/cli.rb
CHANGED
@@ -14,12 +14,20 @@ module YTools::Templates
|
|
14
14
|
header 'Description:'
|
15
15
|
para 'This tool uses an ERB template file and a set of YAML files to generate a merged file. For convenience, all of the keys in hashes in regular YAML can work like methods in the ERB templates. Thus, the YAML "{ \'a\' : {\'b\' : 3 } }" could be used in an ERB template with "<%= a.b %>" instead of the more verbose hash syntax. Indeed, the root hash values can only be accessed by those method attributes, because the root YAML context object is simply assumed.'
|
16
16
|
para "It accepts multiple yaml files, and will merge their contents in the order in which they are given. Thus, files listed later, if their keys conflict with ones listed earlier, override the earlier listed values. If you pass in files that don't exist, no error will be raised unless the '--strict' flag is passed."
|
17
|
+
para "Instead of reading from the template, you can also supply an expression to evaluate from the command line."
|
17
18
|
para "Check out the '--examples' flag for more details."
|
18
19
|
|
19
20
|
header 'Options:'
|
20
|
-
|
21
|
-
required
|
21
|
+
string :template, "The ERB template file to use for generation" do
|
22
22
|
depends_on :examples
|
23
|
+
|
24
|
+
validate do |path, options|
|
25
|
+
if !File.exists?(path)
|
26
|
+
die "file doesn't exist: #{path}"
|
27
|
+
end
|
28
|
+
|
29
|
+
options[:erb] = File.read(path)
|
30
|
+
end
|
23
31
|
end
|
24
32
|
string :output, "Write the generated output to a file instead of STDOUT" do
|
25
33
|
validate do |path, options|
|
@@ -28,6 +36,17 @@ module YTools::Templates
|
|
28
36
|
end
|
29
37
|
end
|
30
38
|
end
|
39
|
+
string :expression, "Evaluate the expression, instead of a given template file." do
|
40
|
+
depends_on :examples, :template
|
41
|
+
|
42
|
+
validate do |expr, options|
|
43
|
+
if options[:template]
|
44
|
+
die "allows only --expression or --template, not both"
|
45
|
+
end
|
46
|
+
|
47
|
+
options[:erb] = expr
|
48
|
+
end
|
49
|
+
end
|
31
50
|
end
|
32
51
|
end
|
33
52
|
end # CLI
|
metadata
CHANGED