groundwork 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/groundwork +53 -6
- data/lib/groundwork.rb +1 -1
- data/lib/options.rb +5 -3
- metadata +2 -2
data/bin/groundwork
CHANGED
@@ -6,15 +6,22 @@ begin
|
|
6
6
|
options = Groundwork::parse_options
|
7
7
|
|
8
8
|
case options[:command]
|
9
|
+
|
10
|
+
##################################################
|
11
|
+
### Generate #####################################
|
12
|
+
##################################################
|
9
13
|
when "generate"
|
14
|
+
|
10
15
|
generate_opts = Trollop::options(options[:remainder]) do
|
11
16
|
banner <<-STR
|
12
17
|
Usage:
|
13
18
|
groundwork generate [options] filename
|
14
|
-
|
15
|
-
|
19
|
+
|
20
|
+
Generates a basic .recipe.rb file, which you can modify, from the current directory
|
21
|
+
|
22
|
+
Options are:
|
16
23
|
STR
|
17
|
-
opt :force, "Overwrite recipe file if exists", :default=>false
|
24
|
+
opt :force, "Overwrite .recipe.rb file if exists", :default=>false
|
18
25
|
opt :ignore, "Ignore files matching these filename patterns", :type=>:strings
|
19
26
|
opt :print, "Instead of storing in a file, print the recipe to stdout", :default=>false
|
20
27
|
opt :chdir, "Before running, cd to the given directory", :default=>FileUtils.pwd
|
@@ -30,11 +37,51 @@ STR
|
|
30
37
|
else
|
31
38
|
name = options[:remainder].shift || "Recipe"
|
32
39
|
|
33
|
-
if File.exists?(name+".recipe") && !generate_opts[:force]
|
34
|
-
raise RuntimeError.new("File already exists: #{name}.recipe")
|
40
|
+
if File.exists?(name+".recipe.rb") && !generate_opts[:force]
|
41
|
+
raise RuntimeError.new("File already exists: #{name}.recipe.rb\nUse -f to overwrite")
|
42
|
+
end
|
43
|
+
|
44
|
+
File.open(name+".recipe.rb","w"){|f| f.print recipe}
|
45
|
+
end
|
46
|
+
|
47
|
+
##################################################
|
48
|
+
### Compile ######################################
|
49
|
+
##################################################
|
50
|
+
when "compile"
|
51
|
+
|
52
|
+
compile_opts = Trollop::options(options[:remainder]) do
|
53
|
+
banner <<-STR
|
54
|
+
Usage:
|
55
|
+
groundwork compile [options] filename.recipe.rb
|
56
|
+
|
57
|
+
Compiles a .recipe.rb, including all referenced files into it.
|
58
|
+
|
59
|
+
Options are:
|
60
|
+
STR
|
61
|
+
opt :force, "Overwrite .recipe file if exists", :default=>false
|
62
|
+
opt :print, "Instead of storing in a file, print the recipe to stdout", :default=>false
|
63
|
+
opt :chdir, "Before running, cd to the given directory", :default=>FileUtils.pwd
|
64
|
+
end
|
65
|
+
|
66
|
+
input = options[:remainder].shift
|
67
|
+
raise RuntimeError.new("No input file given") unless input
|
68
|
+
raise RuntimeError.new("Cannot open #{input}") unless File.exists?(input)
|
69
|
+
|
70
|
+
compiled = ""
|
71
|
+
FileUtils.cd(compile_opts[:chdir]) do
|
72
|
+
compiled = Groundwork::Recipe.compile input
|
73
|
+
end
|
74
|
+
|
75
|
+
if compile_opts[:print]
|
76
|
+
puts compiled
|
77
|
+
else
|
78
|
+
name = options[:remainder].shift || File.basename(input,".recipe.rb")
|
79
|
+
|
80
|
+
if File.exists?(name+".recipe") && !compile_opts[:force]
|
81
|
+
raise RuntimeError.new("File already exists: #{name}.recipe\nUse -f to overwrite")
|
35
82
|
end
|
36
83
|
|
37
|
-
File.open(name+".recipe","w"){|f| f.print
|
84
|
+
File.open(name+".recipe","w"){|f| f.print compiled}
|
38
85
|
end
|
39
86
|
else
|
40
87
|
end
|
data/lib/groundwork.rb
CHANGED
data/lib/options.rb
CHANGED
@@ -6,10 +6,12 @@ module Groundwork
|
|
6
6
|
banner <<-STR
|
7
7
|
Usage:
|
8
8
|
groundwork [global_options] command [command_options]
|
9
|
-
|
9
|
+
|
10
|
+
Currently, the only implemented commands are "generate", which generates a recipe for the current directory, and "compile", which compiles a recipe with all the files it references.
|
11
|
+
|
10
12
|
Options are:
|
11
13
|
STR
|
12
|
-
version "0.0.
|
14
|
+
version "0.0.3"
|
13
15
|
stop_on_unknown
|
14
16
|
end
|
15
17
|
|
@@ -21,7 +23,7 @@ STR
|
|
21
23
|
})
|
22
24
|
end
|
23
25
|
|
24
|
-
def self.short_for cmd_start, all_commands=["generate"]
|
26
|
+
def self.short_for cmd_start, all_commands=["generate", "compile"]
|
25
27
|
return cmd_start unless cmd_start
|
26
28
|
return cmd_start if all_commands.index(cmd_start)
|
27
29
|
|