mast 1.2.0 → 1.3.0

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/HISTORY.rdoc CHANGED
@@ -1,6 +1,26 @@
1
1
  = RELEASE HISTORY
2
2
 
3
- == 1.2 / 2010-02-19
3
+ == 1.3.0 / 2010-11-21
4
+
5
+ Version 1.3 primarily makes a few adjustment under-the-hood. It switches
6
+ GetoptLong out for OptionParser, gets rid of it's dependency on Ruby Facets'
7
+ Kernel#ask method, and changes the diff comment short name from `-d` to `-D`.
8
+ Lowecase `-d` is now used as a short name for the `--dir` option. In the
9
+ process a bug was fixed where this `-d` option was not being added to the
10
+ manifest's bang line. Lastly, the `-s`/`--show` option has been enamed to
11
+ `-b`/`--bang`, which is more descriptive.
12
+
13
+ Changes:
14
+
15
+ * Use `optparse.rb` library instead of `getoptlong.rb`.
16
+ * Remove dependency on Ruby Facets's Kernel#ask method.
17
+ * Rename `-d` to `-D`, short for `--diff`.
18
+ * Add `-d` option to go with `--dir`.
19
+ * Fix issue with `-d` option not added to bang line.
20
+ * Rename `-s`/`--show` option to `-b`/`--bang`.
21
+
22
+
23
+ == 1.2.0 / 2010-02-19
4
24
 
5
25
  This release adjusts the plugins directory to conform
6
26
  to the new Plugin gem and add the -i shortcut to the
@@ -12,7 +32,7 @@ Changes:
12
32
  * Add -i to help output.
13
33
 
14
34
 
15
- == 1.1 / 2009-10-24
35
+ == 1.1.0 / 2009-10-24
16
36
 
17
37
  This release fixes the show and clean commands and makes
18
38
  some additional adjustments under the hood.
@@ -23,7 +43,7 @@ Changes:
23
43
  * Change to MIT license.
24
44
 
25
45
 
26
- == 1.0 / 2009-07-02
46
+ == 1.0.0 / 2009-07-02
27
47
 
28
48
  This is the initial release of Mast.
29
49
 
data/LICENSE CHANGED
@@ -1,23 +1,205 @@
1
- The MIT License
1
+ .
2
2
 
3
- Copyright (c) 2009 Thomas Sawyer
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
4
6
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
8
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
9
+ 1. Definitions.
14
10
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
22
13
 
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
23
16
 
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
204
+
205
+ .
data/README.rdoc CHANGED
@@ -6,9 +6,6 @@
6
6
  | |
7
7
  '-----------'
8
8
 
9
- * home: http://proutils.github.com/mast/
10
- * work: http://github.com/proutils/mast/
11
- * wiki: http://wiki.github.com/proutils/mast/
12
9
 
13
10
  == DESCRIPTION
14
11
 
@@ -24,14 +21,22 @@ or as a stand-alone tool for monitoring file changes.
24
21
  * Checksum digests can highlight file changes.
25
22
 
26
23
 
24
+ == RESOURCES
25
+
26
+ * home: http://rubyworks.github.com/mast/
27
+ * work: http://github.com/rubyworks/mast/
28
+ * wiki: http://wiki.github.com/rubyworks/mast/
29
+
30
+
27
31
  == USAGE
28
32
 
29
- Mast makes the process of generating manifests very easy, and even allows manifests
30
- to be updated without repeating inclusion/exclusion criteria by storing the command
31
- parameters in a comment line at the top of the generated output.
33
+ Mast makes the process of generating manifests very easy, and even allows
34
+ manifests to be updated without repeating inclusion/exclusion criteria by
35
+ storing the command parameters in a comment line at the top of the generated
36
+ output.
32
37
 
33
- Lets try a simple example. Lets say we have the following folder structure, using
34
- <tt>ls -R</tt> we see:
38
+ Lets try a simple example. Lets say we have the following folder structure,
39
+ using <code>ls -R</code> we see:
35
40
 
36
41
  $ ls -R
37
42
  .:
@@ -73,10 +78,12 @@ Now lets look at the same folder via 'mast'.
73
78
  mint/loremipsum.txt
74
79
  mint/tryme.rb
75
80
 
76
- As you can see it has listed all the files contained in the current folder. Notice also the first
77
- line is empty except for the '#' character. This is a standard shell comment mark. We can specify
78
- special criteria to the mast command and these options will be reflected on this line. For example,
79
- lets say the mint directory is extraneous and we do not want it included in the list of files.
81
+ As you can see it has listed all the files contained in the current folder.
82
+ Notice also the first line is empty except for the '#' character. This is
83
+ a standard shell comment mark. We can specify special criteria to the mast
84
+ command and these options will be reflected on this line. For example, lets
85
+ say the mint directory is extraneous and we do not want it included in the
86
+ list of files.
80
87
 
81
88
  $ mast -x mint
82
89
  #!mast -x mint
@@ -91,9 +98,11 @@ lets say the mint directory is extraneous and we do not want it included in the
91
98
  demo_rtar/web/index.html
92
99
  demo_rtar/web/rocklobster.jpg
93
100
 
94
- So you can see how the commandline options carry over to the top comment line of the ouput. The advantage of
95
- this is that if you save the output to a standard location, i.e. a file named MANIFEST or meta/manifest with
96
- an optional .txt prefix (case insensitive), then you can automaitcally update the file by calling +mast --update+.
101
+ So you can see how the commandline options carry over to the top comment line
102
+ of the ouput. The advantage of this is that if you save the output to a standard
103
+ location, i.e. a file named MANIFEST or meta/manifest with an optional `.txt`
104
+ prefix (case insensitive), then you can automaitcally update the file by calling
105
+ <code>mast --update</code>.
97
106
 
98
107
  $ mast -x mint > MANIFEST
99
108
 
@@ -113,23 +122,30 @@ as omitting default excludes and ignores so that all files are lists. Use the
113
122
 
114
123
  To install with RubyGems simply open a console and type:
115
124
 
116
- gem install mast
125
+ $ gem install mast
117
126
 
118
- Local installation requires Setup.rb (gem install setup),
119
- then download the tarball package and type:
127
+ For a traditional site installation use Ruby Setup (gem install setup).
120
128
 
121
- tar -xvzf mast-1.0.0.tgz
122
- cd mast-1.0.0.tgz
123
- sudo setup.rb all
129
+ $ tar -xvzf mast-1.3.0.tar.gz
130
+ $ cd mast-1.3.0.tar.gz
131
+ $ sudo setup.rb
124
132
 
125
- Windows users use 'ruby setup.rb all'.
133
+ See {Ruby Setup}[http://rubyworks.github.com/setup] for more information.
126
134
 
127
135
 
128
136
  == COPYRIGHT
129
137
 
130
- Copyright (c) 2009 Thomas Sawyer <transfire@gmail.com>
138
+ Copyright (c) 2009 Thomas Sawyer
139
+
140
+ Licensed under the Apache License, Version 2.0 (the "License");
141
+ you may not use this file except in compliance with the License.
142
+ You may obtain a copy of the License at
131
143
 
132
- This program is ditributed unser the terms of the MIT license.
144
+ http://www.apache.org/licenses/LICENSE-2.0
133
145
 
134
- See LICENSE or COPYING file for details.
146
+ Unless required by applicable law or agreed to in writing, software
147
+ distributed under the License is distributed on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
+ See the License for the specific language governing permissions and
150
+ limitations under the License.
135
151
 
data/lib/mast.rb CHANGED
@@ -1,5 +1,2 @@
1
- module Mast
2
- VERSION = "1.2.0" #:till: VERSION="<%= version %>"
3
- end
4
-
1
+ require 'mast/meta/data'
5
2
  require 'mast/manifest'
data/lib/mast/cli.rb CHANGED
@@ -19,7 +19,7 @@
19
19
  # -c --create Generate a new manifest. (default)
20
20
  # -u --update Update an existing manifest.
21
21
  # -l --list List the files given in the manifest file. (Use -f to specify an alternate file.)
22
- # -d --diff Diff manifest file against actual.
22
+ # -D --diff Diff manifest file against actual.
23
23
  # -n --new List existant files that are not given in the manifest.
24
24
  # -o --old List files given in the manifest but are non-existent.
25
25
  # --clean Remove non-manifest files. (Will ask for confirmation first.)
@@ -29,9 +29,9 @@
29
29
  # Options:
30
30
  # -a --all Include all files. This deactivates deafult exclusions
31
31
  # so it is possible to make complete list of all contents.
32
- # --dir When creating a list include directory paths; by default
32
+ # -d --dir When creating a list include directory paths; by default
33
33
  # only files are listed.
34
- # -s --show Show files using the options from the manifest file.
34
+ # -b --bang Produce new manifest but using options from the bang line of the manifest file.
35
35
  # -f --file PATH Path to manifest file. This applies to comparison commands.
36
36
  # If not given then the file matching 'MANIFEST', case-insensitive
37
37
  # and with an optional '.txt' extension, in the current directory
@@ -46,14 +46,11 @@
46
46
  # -q --quiet Suppress any extraneous output.
47
47
 
48
48
  require 'mast'
49
-
50
- # both of these can be replaced by using Clio instead.
51
- require 'getoptlong'
52
- require 'facets/kernel/ask'
49
+ require 'optparse'
53
50
 
54
51
  module Mast
55
52
 
56
- ARGVO = ARGV.dup
53
+ #ARGVO = ARGV.dup
57
54
 
58
55
  # Manifest Console Command
59
56
  #
@@ -66,31 +63,30 @@ module Mast
66
63
  DIGESTS = [:md5, :sha1, :sha128, :sha256, :sha512]
67
64
 
68
65
  attr_accessor :quiet
69
- attr_accessor :file
70
- attr_accessor :digest
71
- attr_accessor :ignore
72
- attr_accessor :include
73
- attr_accessor :exclude
74
- attr_accessor :all
75
- attr_accessor :dir
76
- attr_accessor :show
66
+
67
+ # Options for Manifest class taken from commandline arguments.
68
+ attr :options
77
69
 
78
70
  #
79
71
  def initialize
80
- @quiet = false
81
- @all = false
82
- @file = nil
83
- @digest = nil
84
- @exclude = []
85
- @include = []
86
- @ignore = []
72
+ @options = {}
73
+ @options[:all] = false
74
+ @options[:file] = nil
75
+ @options[:bang] = nil
76
+ @options[:digest] = nil
77
+ @options[:exclude] = []
78
+ @options[:ignore] = []
79
+ @options[:include] = []
80
+
87
81
  @command = []
82
+
83
+ @quiet = false
88
84
  end
89
85
 
90
86
  #
91
- def run
87
+ def run(argv=nil)
92
88
  begin
93
- run_command
89
+ run_command(argv)
94
90
  rescue => err
95
91
  raise err if $DEBUG
96
92
  report err
@@ -98,17 +94,24 @@ module Mast
98
94
  end
99
95
 
100
96
  # Run command.
101
- def run_command
102
- optparse
97
+ def run_command(argv)
98
+ argv = (argv || ARGV).dup
99
+
100
+ @original_arguments = argv.dup
101
+
102
+ option_parser.parse!(argv)
103
+
104
+ @options[:include] = argv.empty? ? nil : argv #.dup
105
+
103
106
  if @command.size > 1
104
107
  raise ArgumentError, "Please issue only one command."
105
108
  end
109
+
106
110
  case @command.first
107
111
  when :help then help
108
112
  when :create then generate
109
113
  when :update then update
110
114
  when :list then list
111
- #when :show then show
112
115
  when :diff then diff
113
116
  when :new then new
114
117
  when :old then old
@@ -120,91 +123,66 @@ module Mast
120
123
  end
121
124
 
122
125
  # Parse command line options.
123
- def optparse
124
- opts = GetoptLong.new(
125
- # options
126
- [ '--file' , '-f', GetoptLong::REQUIRED_ARGUMENT ],
127
- [ '--digest' , '-g', GetoptLong::REQUIRED_ARGUMENT ],
128
- [ '--exclude', '-x', GetoptLong::REQUIRED_ARGUMENT ],
129
- #[ '--include', '-i', GetoptLong::REQUIRED_ARGUMENT ],
130
- [ '--ignore' , '-i', GetoptLong::REQUIRED_ARGUMENT ],
131
- [ '--all' , '-a', GetoptLong::NO_ARGUMENT ],
132
- [ '--dir' , GetoptLong::NO_ARGUMENT ],
133
- [ '--show' , '-s', GetoptLong::NO_ARGUMENT ],
134
- [ '--quiet' , '-q', GetoptLong::NO_ARGUMENT ],
135
- # commands
136
- [ '--help' , '-h', GetoptLong::NO_ARGUMENT ],
137
- [ '--create' , '-c', GetoptLong::NO_ARGUMENT ],
138
- [ '--update' , '-u', GetoptLong::NO_ARGUMENT ],
139
- [ '--list' , '-l', GetoptLong::NO_ARGUMENT ],
140
- [ '--diff' , '-d', GetoptLong::NO_ARGUMENT ],
141
- [ '--new' , '-n', GetoptLong::NO_ARGUMENT ],
142
- [ '--old' , '-o', GetoptLong::NO_ARGUMENT ],
143
- [ '--verify' , '-v', GetoptLong::NO_ARGUMENT ],
144
- [ '--clean' , GetoptLong::NO_ARGUMENT ]
145
- )
146
-
147
- opts.each do |key, val|
148
- case key
149
- when '--help'
150
- @command << :help
151
- when '--create'
126
+ def option_parser
127
+ OptionParser.new do |opt|
128
+ opt.on "--file", "-f FILE" do |file|
129
+ @options[:file] = file
130
+ end
131
+ opt.on "--digest", "-g TYPE" do |digest|
132
+ @options[:digest] = digest
133
+ end
134
+ opt.on "--exclude", "-x GLOB" do |glob|
135
+ @options[:exclude] << glob
136
+ end
137
+ opt.on "--ignore", "-i GLOB" do |glob|
138
+ @options[:ignore] << glob
139
+ end
140
+ opt.on "--all", "-a" do |bool|
141
+ @options[:all] = true
142
+ end
143
+ opt.on "--bang", "-b" do |bool|
144
+ @options[:bang] = true
145
+ end
146
+ opt.on "--dir", "-d" do |bool|
147
+ @options[:dir] = bool
148
+ end
149
+ #opt.on "--quiet", "-q", "" do |bool|
150
+ # @quiet = bool
151
+ #end
152
+ opt.on "--create", "-c" do
152
153
  @command << :create
153
- when '--update'
154
+ end
155
+ opt.on "--update", "-u" do
154
156
  @command << :update
155
- when '--list'
157
+ end
158
+ opt.on "--list", "-l" do
156
159
  @command << :list
157
- #when '--show'
158
- # @command << :show
159
- when '--diff'
160
+ end
161
+ opt.on "--diff", "-D" do
160
162
  @command << :diff
161
- when '--new'
163
+ end
164
+ opt.on "--new", "-n" do
162
165
  @command << :new
163
- when '--old'
166
+ end
167
+ opt.on "--old", "-o" do
164
168
  @command << :old
165
- when '--verify'
169
+ end
170
+ opt.on "--verify", "-v" do
166
171
  @command << :verify
167
- when '--clean'
172
+ end
173
+ opt.on "--clean" do
168
174
  @command << :clean
169
-
170
- when '--file'
171
- @file = val
172
- when '--digest'
173
- @digest = val
174
- when '--exclude'
175
- @exclude << val
176
- #when '--include'
177
- # @include << val
178
- #when '--ignore'
179
- # @ignore << val
180
- when '--show'
181
- @show = true
182
- when '--dir'
183
- @dir = true
184
- when '--all'
185
- @all = true
186
- when '--quiet'
187
- @quiet = true
175
+ end
176
+ opt.on "--help" do
177
+ @command << :help
178
+ end
179
+ opt.on "--debug" do
180
+ $DEBUG = true
188
181
  end
189
182
  end
190
-
191
- #unless args.empty?
192
- # if File.file?(args[0])
193
- # opts[:file] = args[0]
194
- # opts[:directory] = args[1] if args[1]
195
- # else
196
- # opts[:directory] = args[0]
197
- # opts[:file] = args[1] if args[1]
198
- # end
199
- #end
200
-
201
- @include = ARGV.empty? ? nil : ARGV.dup
202
183
  end
203
184
 
204
- #def default; generate; end
205
-
206
185
  # Default command -- output manifest.
207
- #
208
186
  def generate
209
187
  #if file
210
188
  # update
@@ -214,7 +192,6 @@ module Mast
214
192
  end
215
193
 
216
194
  # Update a MANIFEST file for this package.
217
- #
218
195
  def update
219
196
  begin
220
197
  file = manifest.update
@@ -287,10 +264,10 @@ module Mast
287
264
 
288
265
  #
289
266
  def manifest
290
- @manifest ||= Manifest.new(manifest_options)
267
+ @manifest ||= Manifest.new(options)
291
268
  #@manifest ||= (
292
269
  # begin
293
- # manifest = Manifest.open(file, manifest_options)
270
+ # manifest = Manifest.open(file, options)
294
271
  # manifest
295
272
  # rescue LoadError
296
273
  # report_manifest_missing
@@ -299,11 +276,6 @@ module Mast
299
276
  #)
300
277
  end
301
278
 
302
- # Options for Manifest class taken from commandline arguments.
303
- def manifest_options
304
- { :file=>file, :digest=>digest, :exclude=>exclude, :ignore=>ignore, :all=>all, :dir=>dir, :include=>include, :show=>show }
305
- end
306
-
307
279
  # Quiet opertation?
308
280
  def quiet?
309
281
  @quiet
@@ -312,13 +284,13 @@ module Mast
312
284
  # Get confirmation for clean.
313
285
  def confirm_clean(list)
314
286
  puts list.join("\n")
315
- ask("The above files will be removed. Continue?", "yN")
287
+ ask("The above files will be removed. Continue? [yN]")
316
288
  end
317
289
 
318
290
  # Get confirmation for clobber.
319
291
  def confirm_clobber(list)
320
292
  puts list.join("\n")
321
- ask("The above files will be removed. Continue?", "yN")
293
+ ask("The above files will be removed. Continue? [yN]")
322
294
  end
323
295
 
324
296
  #
@@ -411,94 +383,14 @@ module Mast
411
383
  report "Manifest is bad!"
412
384
  end
413
385
  end
414
- end
415
386
 
416
- end
417
-
418
- =begin scrap
387
+ #
388
+ def ask(prompt=nil)
389
+ $stdout << "#{prompt}"
390
+ $stdout.flush
391
+ $stdin.gets.chomp!
392
+ end
419
393
 
420
- # # Lookup manifest.
421
- #
422
- # def manifest(create_missing=false)
423
- # @manifest ||= (
424
- # file = @options[:file]
425
- # #manifest = file ? Manifest.open(file) : Manifest.lookup
426
- # manifest = nil
427
- #
428
- # if file
429
- # manifest = Manifest.open(file, @options)
430
- # elsif create_missing
431
- # manifest = Manifest.new(@options)
432
- # else
433
- # manifest = nil
434
- # end
435
- #
436
- # if manifest
437
- # #manifest.send(:set, @options)
438
- # else
439
- # report_manifest_missing
440
- # exit 0
441
- # end
442
- # manifest
443
- # )
444
- # end
445
-
446
- # @manifest ||= (
447
- # file = @options[:file]
448
- # #manifest = file ? Manifest.open(file) : Manifest.lookup
449
- # manifest = nil
450
- #
451
- # if file
452
- # manifest = Manifest.open(file)
453
- # elsif create_missing
454
- # manifest = Manifest.new
455
- # else
456
- # manifest = nil
457
- # end
458
- #
459
- # if manifest
460
- # manifest.change_options(@options)
461
- # else
462
- # report_manifest_missing
463
- # exit 0
464
- # end
465
- # manifest
466
- # )
467
- # end
468
-
469
- # # Generate manifest. By default it is a very simple filename
470
- # # list. The digest can be supplied and a checksum will
471
- # # be given before each filename.
472
- #
473
- # def create
474
- # manifest = Manifest.new #lookup
475
- #
476
- # return report_overwrite(manifest) if (
477
- # manifest and manifest.location == Dir.pwd
478
- # )
479
- #
480
- # report_warn_shadowing(manifest) if manifest
481
- #
482
- # manifest = Manifest.new(options)
483
- # file = manifest.create
484
- # report_created(file)
485
- # end
486
-
487
- # # Clobber non-manifest files.
488
- # #--
489
- # # TODO Should clobber work off the manifest file itself
490
- # #++
491
- #
492
- # def clobber
493
- # ansr = confirm_clobber(manifest.toss)
494
- # case ansr.downcase
495
- # when 'y', 'yes'
496
- # manifest.clobber
497
- # else
498
- # report_cancelled('Clobber')
499
- # exit!
500
- # end
501
- # end
502
-
503
- =end
394
+ end
504
395
 
396
+ end