falsework 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.rdoc +19 -59
  2. data/Rakefile +28 -20
  3. data/bin/falsework +266 -73
  4. data/doc/NEWS.rdoc +24 -0
  5. data/doc/README.rdoc +19 -59
  6. data/doc/TODO.org +16 -6
  7. data/doc/template-tutorial.rdoc +49 -12
  8. data/dynamic.yaml +4 -0
  9. data/falsework.gemspec +10 -1
  10. data/lib/falsework/cliconfig.rb +14 -9
  11. data/lib/falsework/cliutils.rb +0 -2
  12. data/lib/falsework/meta.rb +2 -1
  13. data/lib/falsework/mould.rb +121 -192
  14. data/lib/falsework/upgrader.rb +120 -0
  15. data/lib/falsework/utils.rb +23 -0
  16. data/templates/c-glib/#config.yaml +18 -0
  17. data/{lib/falsework/templates → templates}/c-glib/README +0 -0
  18. data/{lib/falsework/templates → templates}/c-glib/doc/#doc.ascii +0 -0
  19. data/{lib/falsework/templates → templates}/c-glib/doc/%%@project%%.1.asciidoc +0 -0
  20. data/{lib/falsework/templates → templates}/c-glib/doc/LICENSE +0 -0
  21. data/{lib/falsework/templates → templates}/c-glib/doc/Makefile +0 -0
  22. data/{lib/falsework/templates → templates}/c-glib/src/#exe.c +0 -0
  23. data/{lib/falsework/templates → templates}/c-glib/src/#exe.h +0 -0
  24. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.c +0 -0
  25. data/{lib/falsework/templates → templates}/c-glib/src/%%@project%%.h +0 -0
  26. data/{lib/falsework/templates → templates}/c-glib/src/Makefile +0 -0
  27. data/{lib/falsework/templates → templates}/c-glib/src/untest.c +0 -0
  28. data/{lib/falsework/templates → templates}/c-glib/src/untest.h +0 -0
  29. data/{lib/falsework/templates → templates}/c-glib/src/utils.c +0 -0
  30. data/{lib/falsework/templates → templates}/c-glib/src/utils.h +0 -0
  31. data/{lib/falsework/templates → templates}/c-glib/test/#test.c +0 -0
  32. data/{lib/falsework/templates → templates}/c-glib/test/Makefile +0 -0
  33. data/{lib/falsework/templates → templates}/c-glib/test/Makefile.test.mk +0 -0
  34. data/{lib/falsework/templates → templates}/c-glib/test/mycat.c +0 -0
  35. data/{lib/falsework/templates → templates}/c-glib/test/semis/text/empty.txt +0 -0
  36. data/{lib/falsework/templates → templates}/c-glib/test/test_utils.c +0 -0
  37. data/templates/ruby-cli/#config.yaml +26 -0
  38. data/{lib/falsework/templates → templates}/ruby-cli/%%@project%%.gemspec +0 -0
  39. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore +0 -0
  40. data/{lib/falsework/templates → templates}/ruby-cli/.gitignore.#erb +0 -0
  41. data/{lib/falsework/templates → templates}/ruby-cli/Gemfile +0 -0
  42. data/{lib/falsework/templates → templates}/ruby-cli/README.rdoc +17 -19
  43. data/{lib/falsework/templates → templates}/ruby-cli/Rakefile +0 -0
  44. data/{lib/falsework/templates → templates}/ruby-cli/bin/%%@project%% +3 -3
  45. data/{lib/falsework/templates → templates}/ruby-cli/doc/#doc.rdoc +16 -18
  46. data/{lib/falsework/templates → templates}/ruby-cli/doc/LICENSE +0 -0
  47. data/{lib/falsework/templates → templates}/ruby-cli/doc/NEWS.rdoc +0 -0
  48. data/{lib/falsework/templates → templates}/ruby-cli/doc/README.rdoc +17 -19
  49. data/templates/ruby-cli/etc/%%@project%%.yaml +2 -0
  50. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliconfig.rb +14 -11
  51. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/cliutils.rb +0 -4
  52. data/{lib/falsework/templates → templates}/ruby-cli/lib/%%@project%%/meta.rb +1 -0
  53. data/{lib/falsework/templates → templates}/ruby-cli/test/helper.rb +0 -0
  54. data/{lib/falsework/templates → templates}/ruby-cli/test/helper_cliutils.rb +0 -3
  55. data/{lib/falsework/templates → templates}/ruby-cli/test/test_%%@project%%.rb +0 -0
  56. data/test/example/note/full +10 -0
  57. data/test/example/note/project-too-old +8 -0
  58. data/test/example/note/template-unknown +8 -0
  59. data/test/helper.rb +11 -0
  60. data/test/helper_cliutils.rb +0 -1
  61. data/test/templates/config-01.yaml +1 -1
  62. data/test/{test_exe.rb → test_cli.rb} +52 -29
  63. data/test/test_mould.rb +41 -16
  64. data/test/test_upgrader.rb +96 -0
  65. metadata +76 -50
  66. data/dynamic.ruby-cli +0 -3
  67. data/lib/falsework/templates/c-glib/#config.yaml +0 -18
  68. data/lib/falsework/templates/ruby-cli/#config.yaml +0 -15
  69. data/lib/falsework/templates/ruby-cli/etc/%%@project%%.yaml +0 -2
  70. data/test/rake_erb_templates.rb +0 -60
  71. data/test/templates/config-02.yaml +0 -2
  72. data/test/test_cl.rb +0 -33
data/README.rdoc CHANGED
@@ -17,21 +17,23 @@ Initially the template spec was designed only for Ruby projects but
17
17
  later (from version 1.3.0) hard-coded Ruby staff was removed which added
18
18
  more flexibility.
19
19
 
20
- The generated project <b>is not dependent</b> on falsework. The utility
21
- can also add skeletons for tests end executables <i>after</i> the
20
+ Generated projects <b>are not dependent</b> on falsework. The utility
21
+ can also add skeletons for tests end executables <b>after</b> the
22
22
  project generation.
23
23
 
24
24
 
25
25
  ==Ruby Template
26
26
 
27
- ... is default. It generates a scaffold which have:
27
+ ... is default. It generates a scaffold which has:
28
28
 
29
29
  * auto-created git (but not github) project;
30
30
 
31
- * <tt>gem</tt> (a file list is pulled from the git repository, <b>no more
32
- missing files in gems!</b>), <tt>doc</tt>, <tt>test</tt> targets;
31
+ * <tt>gemspec</tt> (a file list is pulled from the git repository),
32
+ <tt>doc</tt>, <tt>test</tt> targets; +build+, +install+ & +release+
33
+ bundler targets.
33
34
 
34
- * easy to use configuration parser/loader. This includes scanning for:
35
+ * easy to use configuration parser/loader. This includes auto-scanning
36
+ for:
35
37
 
36
38
  * env variable(s);
37
39
  * the flat YAML configuration file;
@@ -45,83 +47,41 @@ Version & name of your project can be located at generated
45
47
 
46
48
  ==Options
47
49
 
48
- The commands:
50
+ Run
49
51
 
50
- list:: Do nothing except listing all available
51
- templates. You can add your own templates in
52
- <tt>~/.falsework/templates</tt> directory.
52
+ $ falsework -h
53
53
 
54
- listdirs:: Do nothing except listing all available
55
- templates directories. You can add another
56
- directory by modifying <tt>tdir</tt> option
57
- in the config file. (<tt>tdir</tt> is an
58
- array).
59
-
60
- new NAME:: Create a new project. It creates a directory
61
- <i>NAME</i> and populates it with files.
54
+ to read all possible commands & global options. All of them, except
55
+ +new+ & +list+, work from the root project directory.
62
56
 
63
- The following commands works only from the root project directory:
57
+ Some of the commands support <tt>-h</tt> option too, for example:
64
58
 
65
- exe NAME:: Add a new executable to an existing
66
- project and a corresponding doc in
67
- <tt>doc</tt> sub-directory.
68
-
69
- doc NAME:: Add a new doc file in
70
- <tt>doc</tt> sub-directory.
71
-
72
- test NAME:: Add a new test in
73
- <tt>test</tt> sub-directory.
74
-
75
- upgrade:: 'Inject' or upgrade some vital files from the
76
- template into the project. Currently only
77
- 'ruby-cli' template supports this.
78
-
79
- The options are as follows:
80
-
81
- -t:: A template name.
82
-
83
- -b:: A batch mode. (No questions asked.)
84
-
85
- --no-git:: Don't create a Git repository. Don't use
86
- this for 'ruby-cli' template.
87
-
88
- --config-dirs:: List all possible locations for the
89
- configuration file. The first found wins.
90
-
91
- --config NAME:: The name of the configuration file. If
92
- it contains <tt>/</tt> in it, the list from
93
- <tt>--config-dirs</tt> is ignored.
94
-
95
- -V:: Show falsework version and exit.
96
-
97
- -v:: Be more verbose. You can supply it several
98
- times, viz. <tt>-vv</tt> dumps even more
99
- debug info.
59
+ $ falsework upgrade -h
100
60
 
101
61
 
102
62
  ==Examples
103
63
 
104
64
  Create a new project:
105
65
 
106
- % falsework -v new foobar
66
+ $ falsework -v new foobar
107
67
 
108
68
  Add another CL util to the existing project:
109
69
 
110
- % pwd
70
+ $ pwd
111
71
  .../foobar
112
- % falsework exe foo
72
+ $ falsework exe foo
113
73
 
114
74
  (It will appear in <tt>bin/</tt> sub-directory.)
115
75
 
116
76
  Add another test file:
117
77
 
118
- % falsework test foo
78
+ $ falsework test foo
119
79
 
120
80
  (It will appear in <tt>test/</tt> sub-directory.)
121
81
 
122
82
  Create a project from another template:
123
83
 
124
- % falsework -t c-glib -v new foo-bar
84
+ $ falsework -t c-glib -v new foo-bar
125
85
 
126
86
 
127
87
  ==Bugs
data/Rakefile CHANGED
@@ -2,31 +2,39 @@
2
2
 
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
- require 'bundler/gem_tasks'
6
5
  gem 'rdoc'
7
6
  require 'rdoc/task'
8
7
 
9
- # Generate dynamic targets
10
- require_relative 'test/rake_erb_templates'
11
-
12
- ERB_DYN_SKELETON = erb_skeletons(Meta::NAME, 'ruby-cli')
13
- ERB_DYN_SKELETON.each {|k, v|
14
- file k => [v] do |t|
15
- erb_make(Meta::NAME, 'ruby-cli', t.name, t.prerequisites[0])
16
- end
17
- }
18
-
19
- desc "Generate ruby-cli dynamic files"
20
- file 'dynamic.ruby-cli' => ERB_DYN_SKELETON.keys do |t|
21
- File.open(t.name, 'w+') {|fp|
22
- ERB_DYN_SKELETON.keys.map {|i|
23
- fp.puts i.sub(/#{Dir.pwd}\//, '')
24
- }
8
+ require 'yaml'
9
+ require_relative 'lib/falsework/mould'
10
+
11
+ def src2template target, prerequisite
12
+ src = File.read prerequisite
13
+ src.gsub! /#{Meta::NAME}/, '<%= @project %>'
14
+ src.gsub! /#{Mould.name_camelcase(Meta::NAME)}/, '<%= @camelcase %>'
15
+
16
+ File.open(target, 'w+') {|fp| fp.puts src }
17
+ puts "Created: #{target}"
18
+ end
19
+
20
+ # Create a dynamic target list
21
+ def dynTargets
22
+ YAML.load_file 'dynamic.yaml'
23
+ end
24
+
25
+ DYNAMICS = dynTargets
26
+
27
+ desc "Generate some dynamic template files"
28
+ task :dynamic do
29
+ DYNAMICS.each {|key, val|
30
+ src2template key, val
25
31
  }
26
32
  end
27
33
 
28
34
  # add rubi-cli dynamic files to a clobber target
29
- CLOBBER.concat ERB_DYN_SKELETON.keys
35
+ CLOBBER.concat DYNAMICS.keys
36
+
37
+ require 'bundler/gem_tasks'
30
38
 
31
39
  task default: [:test]
32
40
 
@@ -40,5 +48,5 @@ Rake::TestTask.new do |i|
40
48
  i.test_files = FileList['test/test_*.rb']
41
49
  end
42
50
 
43
- task test: ['dynamic.ruby-cli']
44
- task build: ['dynamic.ruby-cli']
51
+ task test: [:dynamic]
52
+ task build: [:dynamic]
data/bin/falsework CHANGED
@@ -2,28 +2,216 @@
2
2
  # -*-ruby-*-
3
3
 
4
4
  require_relative '../lib/falsework/cliconfig'
5
- require_relative '../lib/falsework/mould'
5
+ require_relative '../lib/falsework/upgrader'
6
6
 
7
7
  include Falsework
8
8
 
9
- $conf = CliConfig.new
10
- $conf[:banner] = <<EOF
11
- Usage: #{File.basename($0)} [options] command ...
12
- Available commands: list, listdirs, (new|exe|doc|test) NAME, upgrade.
13
- EOF
14
- $conf[:user] = nil
15
- $conf[:gecos] = nil
16
- $conf[:email] = nil
17
- $conf[:template] = nil
18
- $conf[:batch] = false
19
- $conf[:git] = true
9
+ module Commands
10
+ extend self
11
+
12
+ FORMAT = {
13
+ 'new' => {
14
+ :help => 'Create a new project',
15
+ :arg => true,
16
+ :code => Proc.new {|arg| newProject arg },
17
+ :optionparse => Proc.new {|arg|
18
+ OptionParser.new do |o|
19
+ o.banner = "Usage: #{File.basename($0)} [options] new [options] NAME"
20
+ o.separator ""
21
+
22
+ o.on('--no-git', "Don't create a git repo.",
23
+ "(Will break 'ruby-cli'.)") { $conf[:git] = false }
24
+ o.on('--no-note', "Don't create a note file.") {
25
+ $conf[:note] = false
26
+ }
27
+
28
+ o.parse!(arg)
29
+ end
30
+ }
31
+ },
32
+
33
+ 'list' => {
34
+ :help => 'List all available templates',
35
+ :code => Proc.new {|arg| list arg},
36
+
37
+ 'dirs' => {
38
+ :help => 'List all reachable template directories',
39
+ :code => Proc.new {|arg| listDirs arg}
40
+ }
41
+ },
42
+
43
+ 'upgrade' => {
44
+ :help => 'Upgrade current project',
45
+ :optionparse => Proc.new {|arg|
46
+ OptionParser.new do |o|
47
+ o.banner = "Usage: #{File.basename($0)} [options] upgrade [options] [command [command]]"
48
+ o.separator ""
49
+ o.on('-b', "Don't ask any questions.") {
50
+ $conf[:upgrader][:batch] = true
51
+ }
52
+ o.on('--save', "Keep old files as a copy with .orig", "extension.") {
53
+ $conf[:upgrader][:save] = true
54
+ }
55
+
56
+ o.parse!(arg)
57
+ end
58
+ },
59
+ :code => Proc.new {|arg| upgrade arg},
60
+
61
+ 'check' => {
62
+ :help => 'Check if project can be upgraded',
63
+ :code => Proc.new {|arg| upgradeCheck arg}
64
+ },
65
+ 'list' => {
66
+ :help => 'List files that will be updated',
67
+ :code => Proc.new {|arg| upgradeListFiles arg },
68
+ 'obsolete' => {
69
+ :help => 'List files that can be deleted',
70
+ :code => Proc.new {|arg| upgradeListObsolete arg }
71
+ }
72
+ }
73
+ },
74
+
75
+ 'exe' => {
76
+ :help => 'Add a new executable to an existing project',
77
+ :arg => true,
78
+ :code => Proc.new {|arg| addFiles 'exe', arg }
79
+ },
80
+ 'doc' => {
81
+ :help => 'Add a new documentation file to an existing project',
82
+ :arg => true,
83
+ :code => Proc.new {|arg| addFiles 'doc', arg }
84
+ },
85
+ 'test' => {
86
+ :help => 'Add a new test file to an existing project',
87
+ :arg => true,
88
+ :code => Proc.new {|arg| addFiles 'test', arg }
89
+ },
90
+ 'file' => {
91
+ :help => 'Add a new file to an existing project',
92
+ :arg => true,
93
+ :code => Proc.new {|arg| addFiles 'file', arg }
94
+ }
95
+ }
96
+
97
+ DELIM = '~<x>~'
98
+
99
+ def tree start, r, indent = ''
100
+ start.each {|key, val|
101
+ next if key.is_a?(Symbol)
102
+
103
+ t = indent
104
+ t += key
105
+ t += ' ARG' if val[:arg]
106
+ t += DELIM + val[:help]
107
+ r[:t] << t
108
+
109
+ # recursion
110
+ tree val, r, indent + ' '
111
+ }
112
+ end
113
+
114
+ def help
115
+ r = {}
116
+ r[:t] = []
117
+ tree FORMAT, r
118
+
119
+ max = 0
120
+ r[:t].each {|idx|
121
+ left = idx.split(DELIM).first
122
+ max = left.size if max < left.size
123
+ }
124
+
125
+ r[:t].each_with_index {|idx, index|
126
+ left = idx.split(DELIM).first
127
+ spaces = ' ' + ('.' * (max - left.size)) + '.... '
128
+ r[:t][index].sub!(/#{DELIM}/, spaces)
129
+ }
130
+
131
+ r[:t].join "\n"
132
+ end
133
+
134
+ def traverse format, argv
135
+ command = argv.first
136
+
137
+ found = false
138
+ format.each {|key, val|
139
+ if key == command
140
+ begin
141
+ format[key][:optionparse].call argv if format[key][:optionparse]
142
+ rescue
143
+ CliUtils.errx EX_USAGE, $!
144
+ end
145
+
146
+ if format[key][:arg] || argv.size == 1
147
+ found = true
148
+ CliUtils.veputs 2, "Executing '#{key}'"
149
+ format[key][:code].call argv[1..-1]
150
+ break
151
+ else
152
+ # recursion
153
+ found = traverse val, argv[1..-1]
154
+ end
155
+ end
156
+ }
157
+
158
+ found
159
+ end
160
+
161
+ end
162
+
163
+ def list args
164
+ Mould.templates.each {|name, loc|
165
+ loc = '(system)' if loc == (Mould.template_dirs.first + name)
166
+ puts "%-30s %s" % [name, loc]
167
+ }
168
+ end
169
+
170
+ def listDirs args
171
+ Mould.template_dirs.each {|idx| puts idx }
172
+ end
173
+
174
+ def newProject args
175
+ CliUtils.errx EX_USAGE, 'missing argument' if args.size == 0
176
+ name = args.first
177
+
178
+ if File.dirname(name) != '.'
179
+ Dir.chdir(File.dirname(name)) rescue CliUtils.errx(EX_UNAVAILABLE, "cannot chdir to '#{File.dirname(name)}'")
180
+ name = File.basename name
181
+ end
182
+
183
+ ok = false
184
+ begin
185
+ m = Mould.new(name, $conf[:template],
186
+ $conf[:user], $conf[:email], $conf[:gecos])
187
+ ok = m.project_seed
188
+ rescue
189
+ CliUtils.errx EX_SOFTWARE, $!
190
+ end
191
+ CliUtils.errx EX_SOFTWARE, "hm, nothing was created" unless ok
192
+
193
+ m.noteCreate if $conf[:note]
194
+
195
+ # create a git repository
196
+ if $conf[:git]
197
+ Dir.chdir m.project
198
+ CliUtils.veputs 1, "Creating a git repository in #{Dir.pwd}... __NNL__"
199
+ g = Git.init
200
+ g.add '.'
201
+ g.commit "Initial import from #{Falsework::Meta::NAME} #{Falsework::Meta::VERSION}."
202
+ CliUtils.veputs 1, 'OK'
203
+ end
204
+ end
20
205
 
21
- def add_files(mode, files)
206
+ def addFiles mode, files
207
+ CliUtils.errx EX_USAGE, 'missing argument(s)' if files.size == 0
208
+
22
209
  r = true
23
210
  m = Mould.new(File.basename(Dir.pwd), $conf[:template],
24
211
  $conf[:user], $conf[:email], $conf[:gecos])
212
+
25
213
  files.each {|i|
26
- created = m.add(mode, i) rescue CliUtils.errx(1, $!.to_s)
214
+ created = m.add(mode, i) rescue CliUtils.errx(1, $!)
27
215
  if created.size > 0
28
216
  created.each {|idx| CliUtils.veputs(1, idx) }
29
217
  else
@@ -31,24 +219,79 @@ def add_files(mode, files)
31
219
  end
32
220
  }
33
221
 
34
- r
222
+ exit 1 unless r
223
+ end
224
+
225
+ def upgradeCheck args
226
+ u = Upgrader.new '.'
227
+ CliUtils.errx EX_UNAVAILABLE, "project '#{u.project}' cannot be upgraded" unless u.able?
228
+ CliUtils.veputs 1, "Yup, it's possible."
229
+ rescue UpgradeError, MouldError
230
+ CliUtils.errx 1, $!
231
+ end
232
+
233
+ def upgradeListFiles args
234
+ u = Upgrader.new '.'
235
+ exit EX_UNAVAILABLE unless u.able?
236
+ u.files.each {|i|
237
+ puts Mould.resolve_filename i, u.getProjectBinding
238
+ }
239
+ rescue UpgradeError, MouldError
240
+ CliUtils.errx 1, $!
241
+ end
242
+
243
+ def upgradeListObsolete args
244
+ u = Upgrader.new '.'
245
+ exit EX_UNAVAILABLE unless u.able?
246
+ exit EX_UNAVAILABLE unless u.obsolete.size > 0
247
+ u.obsolete.each {|i|
248
+ puts Mould.resolve_filename i, u.getProjectBinding
249
+ }
250
+ rescue UpgradeError, MouldError
251
+ CliUtils.errx 1, $!
252
+ end
253
+
254
+ def upgrade args
255
+ u = Upgrader.new '.'
256
+ u.batch = $conf[:upgrader][:batch]
257
+ u.upgrade $conf[:upgrader][:save]
258
+ rescue UpgradeError, MouldError
259
+ CliUtils.errx 1, $!
35
260
  end
36
261
 
37
262
 
38
263
  ### main
39
264
 
265
+ $conf = CliConfig.new
266
+ $conf[:cl_parse_in_order] = true
267
+ $conf[:banner] = <<EOF
268
+ Usage: #{File.basename($0)} [options] command ...
269
+
270
+ Available commands:
271
+
272
+ #{Commands.help}
273
+
274
+ EOF
275
+ $conf[:user] = nil
276
+ $conf[:gecos] = nil
277
+ $conf[:email] = nil
278
+ $conf[:template] = nil
279
+ $conf[:git] = true
280
+ $conf[:note] = true
281
+
282
+ $conf[:upgrader] = {}
283
+ $conf[:upgrader][:batch] = false
284
+ $conf[:upgrader][:save] = false
285
+
40
286
  $conf.load {|o|
41
287
  o.on('--user STR', 'Github user.') {|i| $conf[:user] = i }
42
288
  o.on('--gecos STR', 'A gecos-like string.') {|i| $conf[:gecos] = i }
43
289
  o.on('--email STR') {|i| $conf[:email] = i }
44
- o.on('--no-git', "Don't create a git repo.",
45
- "(Will break 'ruby-cli'.)") { $conf[:git] = false }
290
+
46
291
  o.on('-t NAME', 'A template name.') {|i| $conf[:template] = i }
47
- o.on('-b', 'Run in a batch mode and',
48
- 'don\'t ask any questions.') { $conf[:batch] = true }
49
292
  }
50
293
 
51
- CliUtils.errx(EX_USAGE, $conf[:banner]) if (ARGV.size < 2 && ARGV[0] !~ /list|upgrade/)
294
+ CliUtils.errx(EX_USAGE, $conf[:banner]) if ARGV.size == 0
52
295
 
53
296
  # print our env
54
297
  if $conf[:verbose] >= 2
@@ -57,57 +300,7 @@ if $conf[:verbose] >= 2
57
300
  end
58
301
 
59
302
  # modify a list of available template directories
60
- Mould.template_dirs_add $conf[:tdir].map {|i| Pathname.new i} if $conf[:tdir]
61
-
62
- case ARGV[0]
63
- when 'list'
64
- Mould.templates.each {|name, loc|
65
- loc = '(system)' if loc == (Mould.class_variable_get(:@@template_dirs)[0] + name).to_s
66
- puts "%-30s %s" % [name, loc]
67
- }
68
-
69
- when 'listdirs'
70
- Mould.class_variable_get(:@@template_dirs).each {|idx|
71
- puts idx
72
- }
73
-
74
- when /exe|doc|test/
75
- r1 = add_files ARGV[0], ARGV[1..-1]
76
- r2 = true
77
- (r2 = add_files 'doc', ARGV[1..-1]) if ARGV[0] == 'exe'
78
- exit 1 if !r1 || !r2
79
-
80
- when 'upgrade'
81
- m = Mould.new(File.basename(Dir.pwd), $conf[:template],
82
- $conf[:user], $conf[:email], $conf[:gecos])
83
- m.verbose = true if $conf[:verbose] > 0
84
- m.batch = $conf[:batch]
85
- m.upgrade() rescue CliUtils.errx(1, $!.to_s)
86
-
87
- when 'new'
88
- if File.dirname(ARGV[1]) != '.'
89
- Dir.chdir(File.dirname(ARGV[1])) rescue CliUtils.errx(1, "cannot chdir to '#{File.dirname(ARGV[1])}'")
90
- ARGV[1] = File.basename ARGV[1]
91
- end
303
+ Mould.template_dirs_add $conf['tdir'].map {|i| Pathname.new i} if $conf['tdir']
92
304
 
93
- begin
94
- m = Mould.new(ARGV[1], $conf[:template],
95
- $conf[:user], $conf[:email], $conf[:gecos])
96
- rescue
97
- CliUtils.errx 1, $!
98
- end
99
- m.verbose = true if $conf[:verbose] > 0
100
- m.project_seed
101
-
102
- # create a git repository
103
- if $conf[:git]
104
- Dir.chdir m.project
105
- CliUtils.veputs(1, "Creating a git repository in #{Dir.pwd}... __NNL__")
106
- g = Git.init
107
- g.add '.'
108
- g.commit "Initial import from #{Falsework::Meta::NAME} #{Falsework::Meta::VERSION}."
109
- CliUtils.veputs(1, 'OK')
110
- end
111
- else
112
- CliUtils.errx(1, "unknown command: " + ARGV[0])
113
- end
305
+ found = Commands.traverse Commands::FORMAT, ARGV
306
+ CliUtils.errx EX_USAGE, "unknown command '#{ARGV.join ' '}'" unless found
data/doc/NEWS.rdoc CHANGED
@@ -1,3 +1,27 @@
1
+ === 3.0.0
2
+
3
+ Sun Apr 29 12:22:27 EEST 2012
4
+
5
+ * *INCOMPATIBILITY:* symbols in template's <tt>#config.yaml</tt> are
6
+ strings.
7
+
8
+ * *INCOMPATIBILITY:* 'listdirs' is 'list dirs' now.
9
+
10
+ * *INCOMPATIBILITY:* <tt>:tdir</tt> symbol in falsework.yaml is a string 'tdir'.
11
+
12
+ * *INCOMPATIBILITY:* CLO are parsed from left to right only & some
13
+ options are command-specific, for example, 'falsework new foo -v -t
14
+ c-glib' won't work, because 'new' command doesn't know '-v' and '-t'
15
+ options (they are global).
16
+
17
+ * New command: file.
18
+
19
+ * 'upgrade' command has subcommands: list, list obsolete, check.
20
+
21
+ * Upgrading procedure injects a special 'note' into projects:
22
+ <tt>.falsework</tt> file. Upgraded files are no longer contain
23
+ embedded marks in them.
24
+
1
25
  === 2.1.0
2
26
 
3
27
  Mon Apr 23 16:17:18 EEST 2012