dircat 0.0.5 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +9 -0
- data/VERSION.yml +5 -0
- data/bin/dircat-build +6 -0
- data/bin/dircat-diff +6 -0
- data/bin/dircat-query +6 -0
- data/dircat.gemspec +88 -0
- data/examples/example.rb +10 -0
- data/lib/dircat/cat.rb +192 -0
- data/lib/dircat/cli/dircat_build.rb +92 -83
- data/lib/dircat/cli/dircat_diff.rb +85 -0
- data/lib/dircat/cli/dircat_query.rb +53 -43
- data/lib/dircat/entry.rb +60 -0
- data/lib/dircat/extension_md5.rb +24 -0
- data/lib/dircat/extension_numeric.rb +17 -0
- data/lib/dircat/report.rb +61 -0
- data/lib/dircat.rb +29 -2
- data/spec/dircat/cat_spec.rb +71 -0
- data/spec/dircat/cli/dircat_build_spec.rb +59 -0
- data/spec/dircat/cli/dircat_query_diff_spec.rb +26 -0
- data/spec/dircat/cli/dircat_query_spec.rb +35 -0
- data/spec/dircat/md5_spec.rb +12 -0
- data/spec/dircat/numeric_spec.rb +11 -0
- data/spec/spec_helper.rb +25 -0
- metadata +136 -40
- data/bin/dircat-build.rb +0 -8
- data/bin/dircat-cfr.rb +0 -8
- data/bin/dircat-cmp.rb +0 -8
- data/bin/dircat-query.rb +0 -8
- data/lib/dircat/cli/dircat_cfr.rb +0 -69
- data/lib/dircat/cli/dircat_cmp.rb +0 -65
- data/lib/dircat/dircat.rb +0 -263
- data/test/dircat/tc_dircat.rb +0 -83
- data/test/dircat/tc_dircat_build.rb +0 -43
- data/test/test_dircat.rb +0 -6
- /data/{test_data/dircat/data → spec/fixtures}/certified_output/dircat1.yaml +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/certified_output/dircat2.yaml +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir1/file1.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir1/subdir/file3.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir2/file1.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir2/file2.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir2/subdir/file3.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir3/file1.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/dir3/subdir/file1.txt +0 -0
- /data/{test_data/dircat/data → spec/fixtures}/tmp/dummy.txt +0 -0
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
ADDED
data/VERSION.yml
ADDED
data/bin/dircat-build
ADDED
data/bin/dircat-diff
ADDED
data/bin/dircat-query
ADDED
data/dircat.gemspec
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{dircat}
|
8
|
+
s.version = "0.1.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tokiro"]
|
12
|
+
s.date = %q{2010-12-17}
|
13
|
+
s.description = %q{
|
14
|
+
command line utilites to manage catalogs of directory
|
15
|
+
}
|
16
|
+
s.email = %q{tokiro.oyama@gmail.com}
|
17
|
+
s.executables = ["dircat-build", "dircat-diff", "dircat-query"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION.yml",
|
27
|
+
"dircat.gemspec",
|
28
|
+
"examples/example.rb",
|
29
|
+
"lib/dircat.rb",
|
30
|
+
"lib/dircat/cat.rb",
|
31
|
+
"lib/dircat/cli/dircat_build.rb",
|
32
|
+
"lib/dircat/cli/dircat_diff.rb",
|
33
|
+
"lib/dircat/cli/dircat_query.rb",
|
34
|
+
"lib/dircat/entry.rb",
|
35
|
+
"lib/dircat/extension_md5.rb",
|
36
|
+
"lib/dircat/extension_numeric.rb",
|
37
|
+
"lib/dircat/report.rb"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/tokiro/dircat}
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
42
|
+
s.summary = %q{command line utilites to manage catalogs of directory}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/dircat/cat_spec.rb",
|
45
|
+
"spec/dircat/cli/dircat_build_spec.rb",
|
46
|
+
"spec/dircat/cli/dircat_query_diff_spec.rb",
|
47
|
+
"spec/dircat/cli/dircat_query_spec.rb",
|
48
|
+
"spec/dircat/md5_spec.rb",
|
49
|
+
"spec/dircat/numeric_spec.rb",
|
50
|
+
"spec/fixtures/certified_output/dircat1.yaml",
|
51
|
+
"spec/fixtures/certified_output/dircat2.yaml",
|
52
|
+
"spec/fixtures/dir1/file1.txt",
|
53
|
+
"spec/fixtures/dir1/subdir/file3.txt",
|
54
|
+
"spec/fixtures/dir2/file1.txt",
|
55
|
+
"spec/fixtures/dir2/file2.txt",
|
56
|
+
"spec/fixtures/dir2/subdir/file3.txt",
|
57
|
+
"spec/fixtures/dir3/file1.txt",
|
58
|
+
"spec/fixtures/dir3/subdir/file1.txt",
|
59
|
+
"spec/fixtures/tmp/dummy.txt",
|
60
|
+
"spec/spec_helper.rb"
|
61
|
+
]
|
62
|
+
|
63
|
+
if s.respond_to? :specification_version then
|
64
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
65
|
+
s.specification_version = 3
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
70
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
76
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
77
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
83
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
84
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
85
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
data/examples/example.rb
ADDED
data/lib/dircat/cat.rb
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
module DirCat
|
2
|
+
|
3
|
+
class Cat
|
4
|
+
|
5
|
+
attr_reader :dirname
|
6
|
+
|
7
|
+
# data di creazione
|
8
|
+
attr_reader :ctime
|
9
|
+
attr_writer :ctime
|
10
|
+
|
11
|
+
def initialize( options = {} )
|
12
|
+
@verbose_level = options.delete(:verbose) || 0
|
13
|
+
@dirname = ""
|
14
|
+
@ctime = DateTime.now
|
15
|
+
@entries = Array.new
|
16
|
+
@md5ToEntries = Hash.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def from_dir( dirname )
|
20
|
+
if not File.directory?( dirname )
|
21
|
+
raise "'#{dirname}' is not a directory or doesn't exists"
|
22
|
+
end
|
23
|
+
@dirname = File.expand_path dirname
|
24
|
+
@ctime = DateTime.now
|
25
|
+
_loadfromdir
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.from_dir( dirname, options = {} )
|
30
|
+
new(options).from_dir(dirname)
|
31
|
+
end
|
32
|
+
|
33
|
+
def from_file( filename )
|
34
|
+
if not File.exist?( filename )
|
35
|
+
raise DirCatException.new, "'#{filename}' not exists"
|
36
|
+
end
|
37
|
+
dircat_ser = YAML::load( File.open( filename ) )
|
38
|
+
@dirname = dircat_ser.dirname
|
39
|
+
@ctime = dircat_ser.ctime
|
40
|
+
dircat_ser.entries.each{ |entry_ser|
|
41
|
+
add_entry( Entry.new.from_ser( entry_ser ) )
|
42
|
+
}
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.from_file( filename, options = {} )
|
47
|
+
new(options).from_file(filename)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_ser
|
51
|
+
dircat_ser = DirCatSer.new
|
52
|
+
dircat_ser.version = 0.1
|
53
|
+
dircat_ser.dirname = @dirname
|
54
|
+
dircat_ser.ctime = @ctime
|
55
|
+
dircat_ser.entries = []
|
56
|
+
@entries.each { |entry|
|
57
|
+
dircat_ser.entries << entry.to_ser
|
58
|
+
}
|
59
|
+
dircat_ser
|
60
|
+
end
|
61
|
+
|
62
|
+
def _loadfromdir()
|
63
|
+
old_dirname = Dir.pwd
|
64
|
+
Dir.chdir( @dirname )
|
65
|
+
Dir["**/*"].each { |f|
|
66
|
+
next if File.directory?( f )
|
67
|
+
|
68
|
+
if @verbose_level > 0
|
69
|
+
cr = "\r"
|
70
|
+
clear = "\e[K"
|
71
|
+
print "#{cr}#{filename}#{clear}"
|
72
|
+
end
|
73
|
+
|
74
|
+
add_entry( Entry.new.from_filename( f ) )
|
75
|
+
}
|
76
|
+
if @verbose_level > 0
|
77
|
+
print "\n"
|
78
|
+
end
|
79
|
+
Dir.chdir( old_dirname )
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def save_to( file )
|
84
|
+
if file.kind_of?(String)
|
85
|
+
begin
|
86
|
+
File.open( file, "w" ) do |f|
|
87
|
+
f.puts to_ser.to_yaml
|
88
|
+
end
|
89
|
+
rescue Errno::ENOENT
|
90
|
+
raise DirCatException.new, "DirCat: cannot write into '#{file}'", caller
|
91
|
+
end
|
92
|
+
else
|
93
|
+
file.puts to_ser.to_yaml
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def size
|
98
|
+
@entries.size
|
99
|
+
end
|
100
|
+
|
101
|
+
def bytes
|
102
|
+
@entries.inject(0) {|sum, entry| sum + entry.size }
|
103
|
+
end
|
104
|
+
|
105
|
+
def report
|
106
|
+
dups = duplicates
|
107
|
+
s = "Base dir: #@dirname\n" +
|
108
|
+
"Nr. file: #{size}\n" +
|
109
|
+
"Bytes: #{bytes.with_separator}"
|
110
|
+
if duplicates.size > 0
|
111
|
+
s+= "\n duplicates #{dups.size}"
|
112
|
+
end
|
113
|
+
s
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_entry( e )
|
117
|
+
@entries.push( e )
|
118
|
+
if @md5ToEntries.has_key?( e.md5 )
|
119
|
+
# puts "Entry duplicata!!!"
|
120
|
+
@md5ToEntries[ e.md5 ].push( e )
|
121
|
+
else
|
122
|
+
@md5ToEntries[ e.md5 ] = [ e ]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def contains( e )
|
127
|
+
@md5ToEntries.has_key?( e.md5 )
|
128
|
+
end
|
129
|
+
|
130
|
+
def -(s)
|
131
|
+
result = Cat.new
|
132
|
+
@entries.each { |e|
|
133
|
+
result.add_entry(e) unless s.contains(e)
|
134
|
+
}
|
135
|
+
result
|
136
|
+
end
|
137
|
+
|
138
|
+
def duplicates
|
139
|
+
list = []
|
140
|
+
@md5ToEntries.each_value do |ee|
|
141
|
+
next if ee.size < 2
|
142
|
+
list.push( ee )
|
143
|
+
end
|
144
|
+
list
|
145
|
+
end
|
146
|
+
|
147
|
+
def fmt_simple
|
148
|
+
@entries.each { |e|
|
149
|
+
print e.to_s
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
def fmt_report
|
154
|
+
DirCat::report(@entries, :md5, :name, :path)
|
155
|
+
end
|
156
|
+
|
157
|
+
def fmt_ruby( dst )
|
158
|
+
puts "require 'fileutils'"
|
159
|
+
@entries.each { |entry|
|
160
|
+
src = File.join( @dirname, entry.path, entry.name );
|
161
|
+
puts "FileUtils.cp( \"#{src}\", \"#{dst}\" )"
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
def list_dup
|
166
|
+
r = ""
|
167
|
+
duplicates.flatten.each { |e|
|
168
|
+
r += e.to_s + "\n"
|
169
|
+
}
|
170
|
+
r
|
171
|
+
end
|
172
|
+
|
173
|
+
def script_dup
|
174
|
+
r = "require 'fileutils'\n"
|
175
|
+
duplicates.each { |entries|
|
176
|
+
flg_first = true
|
177
|
+
r += "\n"
|
178
|
+
entries.each{ |entry|
|
179
|
+
src = File.join( @dirname, entry.path, entry.name );
|
180
|
+
if flg_first
|
181
|
+
flg_first = false
|
182
|
+
r += "# FileUtils.mv( \"#{src}\", \"#{Dir.tmpdir}\" )\n"
|
183
|
+
else
|
184
|
+
r += "FileUtils.mv( \"#{src}\", \"#{Dir.tmpdir}\" )\n"
|
185
|
+
end
|
186
|
+
}
|
187
|
+
}
|
188
|
+
r
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
@@ -1,105 +1,114 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module DirCat
|
2
|
+
#
|
3
|
+
# Build a catalogue starting from a directory
|
4
|
+
#
|
5
|
+
class DirCatBuild
|
6
|
+
|
7
|
+
def self.run
|
8
|
+
return self.new.parse_args( ARGV )
|
9
|
+
end
|
3
10
|
|
4
|
-
|
5
|
-
|
11
|
+
def parse_args( argv )
|
12
|
+
options = { :verbose => true, :force => false }
|
13
|
+
opts = OptionParser.new
|
14
|
+
opts.banner << "Usage: dircat-build [options]\n"
|
15
|
+
opts.banner << "\n"
|
16
|
+
opts.banner << "Build a catalogue starting from a directory\n";
|
17
|
+
opts.banner << "\n"
|
18
|
+
|
19
|
+
opts.on("-h", "--help", "Print this message") do
|
20
|
+
puts opts
|
21
|
+
return 0
|
22
|
+
end
|
6
23
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
24
|
+
opts.on("--version", "show the dircat version") do
|
25
|
+
puts "dircat version #{DirCat::version}"
|
26
|
+
return 0
|
27
|
+
end
|
11
28
|
|
12
|
-
|
13
|
-
|
14
|
-
|
29
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
30
|
+
options[:verbose] = v
|
31
|
+
end
|
15
32
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
opts.banner << "Usage: dircat_build [options]\n"
|
20
|
-
opts.banner << "\n"
|
21
|
-
opts.banner << "Build a catalogue starting from a directory\n";
|
22
|
-
opts.banner << "\n"
|
23
|
-
|
24
|
-
opts.on("-h", "--help", "Print this message") do
|
25
|
-
puts opts
|
26
|
-
return
|
27
|
-
end
|
33
|
+
opts.on("-q", "--quiet", "quiet mode as --no-verbose") do |v|
|
34
|
+
options[:verbose] = false
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
opts.on("-f", "--force", "force write on existent file") do |v|
|
38
|
+
options[:force] = true
|
39
|
+
end
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
|
41
|
+
opts.on("-o [FILE]", "--output [FILE]",String) do |v|
|
42
|
+
if options[:output]
|
43
|
+
puts "only one file of output can be used"
|
44
|
+
return 1
|
45
|
+
end
|
46
|
+
options[:output] = v
|
47
|
+
end
|
36
48
|
|
37
|
-
|
38
|
-
options[:force] = true
|
39
|
-
end
|
49
|
+
rest = opts.parse(argv)
|
40
50
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
51
|
+
# p options
|
52
|
+
# p ARGV
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
if rest.length < 1
|
55
|
+
puts "directory (from which build catalog) is missing"
|
56
|
+
puts "-h to print help"
|
57
|
+
return 0
|
58
|
+
end
|
49
59
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
return
|
54
|
-
end
|
60
|
+
dirname = rest[0]
|
61
|
+
dirname = File.expand_path( dirname )
|
62
|
+
cat_opts = {}
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
return
|
61
|
-
end
|
64
|
+
if not FileTest.directory?(dirname)
|
65
|
+
puts "'#{dirname}' not exists or is not a directory"
|
66
|
+
return 0
|
67
|
+
end
|
62
68
|
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
#
|
70
|
+
# option verbose
|
71
|
+
#
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
if options.has_key?(:verbose)
|
74
|
+
if options[:verbose]
|
75
|
+
cat_opts[:verbose_level] = 1
|
76
|
+
end
|
70
77
|
end
|
71
|
-
end
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
#
|
80
|
+
# option: output, force
|
81
|
+
#
|
82
|
+
output = $stdout
|
83
|
+
if options.has_key?(:output)
|
84
|
+
if options[:output]
|
85
|
+
filename = options[:output]
|
86
|
+
else
|
87
|
+
filename = "cat_" + File.basename( dirname ) + "_" + Date.today.strftime("%Y%m%d") + ".yaml"
|
88
|
+
end
|
89
|
+
if File.exist?(filename) and not options[:force]
|
90
|
+
puts "catalog '#{filename}' exists use --force or -f to overwrite"
|
91
|
+
return 0
|
92
|
+
end
|
93
|
+
output = File.open(filename, "w")
|
82
94
|
end
|
83
|
-
if File.exist?(filename) and not options[:force]
|
84
|
-
puts "File #{filename} exists use --force or -f to overwrite"
|
85
|
-
return
|
86
|
-
end
|
87
|
-
output = File.open(filename, "w")
|
88
|
-
end
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
96
|
+
start_time = Time.now
|
97
|
+
s = Cat.from_dir(dirname)
|
98
|
+
end_time = Time.now
|
99
|
+
|
100
|
+
# s.pr
|
101
|
+
# f.puts s.to_yaml
|
102
|
+
s.save_to( output )
|
93
103
|
|
94
|
-
|
95
|
-
|
96
|
-
|
104
|
+
if output != $stdout
|
105
|
+
output.close
|
106
|
+
end
|
107
|
+
$stderr.puts s.report
|
108
|
+
$stderr.puts "elapsed: #{end_time - start_time}"
|
97
109
|
|
98
|
-
|
99
|
-
output.close
|
110
|
+
0
|
100
111
|
end
|
101
|
-
$stderr.puts s.report
|
102
|
-
$stderr.puts "tempo: #{end_datetime - start_datetime}"
|
103
|
-
end
|
104
112
|
|
113
|
+
end
|
105
114
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module DirCat
|
2
|
+
|
3
|
+
class DirCatDiff
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
return self.new.parse_args( ARGV )
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse_args( args )
|
10
|
+
options = {}
|
11
|
+
opts = OptionParser.new
|
12
|
+
opts.banner =
|
13
|
+
"Usage: dircat_cfr.rb [options] <filedircat1> <filedircat2>\n\n" +
|
14
|
+
"fa la differenza fra il primo catalog e il secondo\n" +
|
15
|
+
"<filedircat1> - <filedircat2>\n" +
|
16
|
+
"e stampa sull'output con un formato\n"
|
17
|
+
|
18
|
+
opts.on("-h", "--help", "Print this message") do
|
19
|
+
puts opts
|
20
|
+
return 0
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("--version", "show the dircat version") do
|
24
|
+
puts "dircat version #{DirCat::version}"
|
25
|
+
return 0
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
29
|
+
options[:verbose] = v
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on("-f FORMAT", "--fmt FORMAT", "formato") do |v|
|
33
|
+
options[:fmt] = v
|
34
|
+
end
|
35
|
+
rest = opts.parse( args )
|
36
|
+
|
37
|
+
# p options
|
38
|
+
# p ARGV
|
39
|
+
|
40
|
+
if rest.length < 2
|
41
|
+
puts "you must provide two args (catalogs or directory)"
|
42
|
+
puts "dircat_cfr -h to print help"
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
cat_filename1 = rest[0]
|
47
|
+
cat_filename2 = rest[1]
|
48
|
+
|
49
|
+
if File.exists?( cat_filename1 )
|
50
|
+
puts "load catalog #{cat_filename1}"
|
51
|
+
s1 = Cat.from_file(cat_filename1)
|
52
|
+
elsif File.directory?(cat_filename1)
|
53
|
+
puts "build first set from directory #{cat_filename1}"
|
54
|
+
s1 = Cat.from_dir(cat_filename1)
|
55
|
+
else
|
56
|
+
puts "#{cat_filename1} is not a catalog file or directory"
|
57
|
+
return 1
|
58
|
+
end
|
59
|
+
|
60
|
+
if File.exists?( cat_filename2 )
|
61
|
+
puts "load catalog #{cat_filename2}"
|
62
|
+
s2 = Cat.from_file(cat_filename2)
|
63
|
+
elsif File.directory?(cat_filename2)
|
64
|
+
puts "build first set from directory #{cat_filename2}"
|
65
|
+
s2 = Cat.from_dir(cat_filename2)
|
66
|
+
else
|
67
|
+
puts "#{cat_filename2} is not a catalog file or directory"
|
68
|
+
return 1
|
69
|
+
end
|
70
|
+
|
71
|
+
puts "build difference"
|
72
|
+
s3 = s1 - s2
|
73
|
+
|
74
|
+
case options[:fmt]
|
75
|
+
when "simple"
|
76
|
+
s3.fmt_simple
|
77
|
+
when "ruby"
|
78
|
+
s3.fmt_ruby( "." )
|
79
|
+
else
|
80
|
+
s3.fmt_simple
|
81
|
+
end
|
82
|
+
0
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|