dircat 0.1.4 → 0.1.5
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/LICENSE +1 -1
- data/VERSION.yml +1 -1
- data/bin/dircat +7 -0
- data/dircat.gemspec +18 -9
- data/lib/dircat/cat.rb +1 -0
- data/lib/dircat/cli/cli_dircat.rb +29 -0
- data/lib/dircat/cli/command_build.rb +201 -0
- data/lib/dircat/cli/command_diff.rb +158 -0
- data/lib/dircat/cli/command_query.rb +138 -0
- data/lib/dircat/entry.rb +1 -0
- data/lib/dircat/extension_md5.rb +3 -2
- data/lib/dircat/extension_numeric.rb +1 -0
- data/lib/dircat/report.rb +1 -0
- data/lib/dircat.rb +11 -4
- data/spec/dircat/cli/cli_dircat_spec.rb +30 -0
- data/spec/dircat/cli/command_build_spec.rb +49 -0
- data/spec/dircat/cli/command_diff_spec.rb +13 -0
- data/spec/dircat/cli/command_query_spec.rb +26 -0
- data/spec/dircat/md5_spec.rb +1 -1
- metadata +55 -28
- data/bin/dircat-build +0 -6
- data/bin/dircat-diff +0 -6
- data/bin/dircat-query +0 -6
- data/lib/dircat/cli/dircat_build.rb +0 -114
- data/lib/dircat/cli/dircat_diff.rb +0 -85
- data/lib/dircat/cli/dircat_query.rb +0 -69
- data/spec/dircat/cli/dircat_build_spec.rb +0 -59
- data/spec/dircat/cli/dircat_query_diff_spec.rb +0 -26
- data/spec/dircat/cli/dircat_query_spec.rb +0 -35
data/LICENSE
CHANGED
data/VERSION.yml
CHANGED
data/bin/dircat
ADDED
data/dircat.gemspec
CHANGED
@@ -5,16 +5,17 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dircat}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tokiro"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-16}
|
13
|
+
s.default_executable = %q{dircat}
|
13
14
|
s.description = %q{
|
14
15
|
command line utilites to manage catalogs of directory
|
15
16
|
}
|
16
17
|
s.email = %q{tokiro.oyama@gmail.com}
|
17
|
-
s.executables = ["dircat
|
18
|
+
s.executables = ["dircat"]
|
18
19
|
s.extra_rdoc_files = [
|
19
20
|
"LICENSE",
|
20
21
|
"README.rdoc"
|
@@ -28,9 +29,10 @@ Gem::Specification.new do |s|
|
|
28
29
|
"examples/example.rb",
|
29
30
|
"lib/dircat.rb",
|
30
31
|
"lib/dircat/cat.rb",
|
31
|
-
"lib/dircat/cli/
|
32
|
-
"lib/dircat/cli/
|
33
|
-
"lib/dircat/cli/
|
32
|
+
"lib/dircat/cli/cli_dircat.rb",
|
33
|
+
"lib/dircat/cli/command_build.rb",
|
34
|
+
"lib/dircat/cli/command_diff.rb",
|
35
|
+
"lib/dircat/cli/command_query.rb",
|
34
36
|
"lib/dircat/entry.rb",
|
35
37
|
"lib/dircat/extension_md5.rb",
|
36
38
|
"lib/dircat/extension_numeric.rb",
|
@@ -42,9 +44,10 @@ Gem::Specification.new do |s|
|
|
42
44
|
s.summary = %q{command line utilites to manage catalogs of directory}
|
43
45
|
s.test_files = [
|
44
46
|
"spec/dircat/cat_spec.rb",
|
45
|
-
"spec/dircat/cli/
|
46
|
-
"spec/dircat/cli/
|
47
|
-
"spec/dircat/cli/
|
47
|
+
"spec/dircat/cli/cli_dircat_spec.rb",
|
48
|
+
"spec/dircat/cli/command_build_spec.rb",
|
49
|
+
"spec/dircat/cli/command_diff_spec.rb",
|
50
|
+
"spec/dircat/cli/command_query_spec.rb",
|
48
51
|
"spec/dircat/md5_spec.rb",
|
49
52
|
"spec/dircat/numeric_spec.rb",
|
50
53
|
"spec/fixtures/certified_output/dircat1.yaml",
|
@@ -65,12 +68,16 @@ Gem::Specification.new do |s|
|
|
65
68
|
s.specification_version = 3
|
66
69
|
|
67
70
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
71
|
+
s.add_runtime_dependency(%q<treevisitor>, [">= 0"])
|
72
|
+
s.add_runtime_dependency(%q<optparse-command>, ["= 0.1.0"])
|
68
73
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
69
74
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
70
75
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
71
76
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
72
77
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
73
78
|
else
|
79
|
+
s.add_dependency(%q<treevisitor>, [">= 0"])
|
80
|
+
s.add_dependency(%q<optparse-command>, ["= 0.1.0"])
|
74
81
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
82
|
s.add_dependency(%q<rake>, [">= 0"])
|
76
83
|
s.add_dependency(%q<yard>, [">= 0"])
|
@@ -78,6 +85,8 @@ Gem::Specification.new do |s|
|
|
78
85
|
s.add_dependency(%q<rspec>, [">= 0"])
|
79
86
|
end
|
80
87
|
else
|
88
|
+
s.add_dependency(%q<treevisitor>, [">= 0"])
|
89
|
+
s.add_dependency(%q<optparse-command>, ["= 0.1.0"])
|
81
90
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
82
91
|
s.add_dependency(%q<rake>, [">= 0"])
|
83
92
|
s.add_dependency(%q<yard>, [">= 0"])
|
data/lib/dircat/cat.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class CliDirCat < CliMain
|
4
|
+
|
5
|
+
def self.command
|
6
|
+
"dircat"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Simple set of command to build catalogs of files."
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.version
|
14
|
+
puts DirCat::version
|
15
|
+
end
|
16
|
+
|
17
|
+
def defaults
|
18
|
+
OpenStruct.new(
|
19
|
+
:verbose => true,
|
20
|
+
:force => false
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def opt_parser(options)
|
25
|
+
opt_parser = super(options)
|
26
|
+
opt_parser
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class CommandBuild < CliCommand
|
4
|
+
|
5
|
+
def self.command
|
6
|
+
"build"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Build a catalogue starting from a directory"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.usage
|
14
|
+
"Usage: dircat build [options]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def opt_parser(options)
|
18
|
+
opt_parser = super(options)
|
19
|
+
|
20
|
+
opt_parser.on("-o [FILE]", "--output [FILE]", String) do |v|
|
21
|
+
if options.output
|
22
|
+
puts "only one file of output can be used"
|
23
|
+
options.exit = true
|
24
|
+
end
|
25
|
+
options.output = v
|
26
|
+
end
|
27
|
+
|
28
|
+
opt_parser.on("-f", "--force", "force write on existent file") do |v|
|
29
|
+
options.force
|
30
|
+
end
|
31
|
+
|
32
|
+
opt_parser
|
33
|
+
end
|
34
|
+
|
35
|
+
def exec(options, rest)
|
36
|
+
if rest.length < 1
|
37
|
+
puts "directory (from which build catalog) is missing"
|
38
|
+
puts "-h to print help"
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
dirname = rest[0]
|
43
|
+
dirname = File.expand_path(dirname)
|
44
|
+
cat_opts = {}
|
45
|
+
|
46
|
+
if not FileTest.directory?(dirname)
|
47
|
+
puts "'#{dirname}' not exists or is not a directory"
|
48
|
+
return 0
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# option verbose
|
53
|
+
#
|
54
|
+
|
55
|
+
if options.verbose
|
56
|
+
cat_opts[:verbose_level] = 1
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# option: output, force
|
61
|
+
#
|
62
|
+
output = $stdout
|
63
|
+
if options.output
|
64
|
+
filename = options.output
|
65
|
+
else
|
66
|
+
filename = "cat_" + File.basename(dirname) + "_" + Date.today.strftime("%Y%m%d") + ".yaml"
|
67
|
+
end
|
68
|
+
if File.exist?(filename) and not options.force
|
69
|
+
puts "catalog '#{filename}' exists use --force or -f to overwrite"
|
70
|
+
return 0
|
71
|
+
end
|
72
|
+
output = File.open(filename, "w")
|
73
|
+
|
74
|
+
start_time = Time.now
|
75
|
+
s = Cat.from_dir(dirname)
|
76
|
+
end_time = Time.now
|
77
|
+
|
78
|
+
# s.pr
|
79
|
+
# f.puts s.to_yaml
|
80
|
+
s.save_to(output)
|
81
|
+
|
82
|
+
if output != $stdout
|
83
|
+
output.close
|
84
|
+
end
|
85
|
+
$stderr.puts s.report
|
86
|
+
$stderr.puts "elapsed: #{end_time - start_time}"
|
87
|
+
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
#module DirCat
|
95
|
+
# #
|
96
|
+
# # Build a catalogue starting from a directory
|
97
|
+
# #
|
98
|
+
# class DirCatBuild
|
99
|
+
#
|
100
|
+
# def self.run
|
101
|
+
# return self.new.parse_args( ARGV )
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# def parse_args( argv )
|
105
|
+
# options = { :verbose => true, :force => false }
|
106
|
+
# opts = OptionParser.new
|
107
|
+
# opts.banner << "\n"
|
108
|
+
# opts.banner << "Build a catalogue starting from a directory\n";
|
109
|
+
# opts.banner << "\n"
|
110
|
+
#
|
111
|
+
# opts.on("-h", "--help", "Print this message") do
|
112
|
+
# puts opts
|
113
|
+
# return 0
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
117
|
+
# options[:verbose] = v
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# opts.on("-q", "--quiet", "quiet mode as --no-verbose") do |v|
|
121
|
+
# options[:verbose] = false
|
122
|
+
# end
|
123
|
+
#
|
124
|
+
# opts.on("-f", "--force", "force write on existent file") do |v|
|
125
|
+
# options[:force] = true
|
126
|
+
# end
|
127
|
+
#
|
128
|
+
# opts.on("-o [FILE]", "--output [FILE]",String) do |v|
|
129
|
+
# if options[:output]
|
130
|
+
# puts "only one file of output can be used"
|
131
|
+
# return 1
|
132
|
+
# end
|
133
|
+
# options[:output] = v
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# rest = opts.parse(argv)
|
137
|
+
#
|
138
|
+
# # p options
|
139
|
+
# # p ARGV
|
140
|
+
#
|
141
|
+
# if rest.length < 1
|
142
|
+
# puts "directory (from which build catalog) is missing"
|
143
|
+
# puts "-h to print help"
|
144
|
+
# return 0
|
145
|
+
# end
|
146
|
+
#
|
147
|
+
# dirname = rest[0]
|
148
|
+
# dirname = File.expand_path( dirname )
|
149
|
+
# cat_opts = {}
|
150
|
+
#
|
151
|
+
# if not FileTest.directory?(dirname)
|
152
|
+
# puts "'#{dirname}' not exists or is not a directory"
|
153
|
+
# return 0
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
# #
|
157
|
+
# # option verbose
|
158
|
+
# #
|
159
|
+
#
|
160
|
+
# if options.has_key?(:verbose)
|
161
|
+
# if options[:verbose]
|
162
|
+
# cat_opts[:verbose_level] = 1
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# #
|
167
|
+
# # option: output, force
|
168
|
+
# #
|
169
|
+
# output = $stdout
|
170
|
+
# if options.has_key?(:output)
|
171
|
+
# if options[:output]
|
172
|
+
# filename = options[:output]
|
173
|
+
# else
|
174
|
+
# filename = "cat_" + File.basename( dirname ) + "_" + Date.today.strftime("%Y%m%d") + ".yaml"
|
175
|
+
# end
|
176
|
+
# if File.exist?(filename) and not options[:force]
|
177
|
+
# puts "catalog '#{filename}' exists use --force or -f to overwrite"
|
178
|
+
# return 0
|
179
|
+
# end
|
180
|
+
# output = File.open(filename, "w")
|
181
|
+
# end
|
182
|
+
#
|
183
|
+
# start_time = Time.now
|
184
|
+
# s = Cat.from_dir(dirname)
|
185
|
+
# end_time = Time.now
|
186
|
+
#
|
187
|
+
# # s.pr
|
188
|
+
# # f.puts s.to_yaml
|
189
|
+
# s.save_to( output )
|
190
|
+
#
|
191
|
+
# if output != $stdout
|
192
|
+
# output.close
|
193
|
+
# end
|
194
|
+
# $stderr.puts s.report
|
195
|
+
# $stderr.puts "elapsed: #{end_time - start_time}"
|
196
|
+
#
|
197
|
+
# 0
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# end
|
201
|
+
#end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class CommandDiff < CliCommand
|
4
|
+
|
5
|
+
def self.command
|
6
|
+
"diff"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"Show diff from two catalogs"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.usage
|
14
|
+
<<-EOS
|
15
|
+
Usage: dircat diff [options] <filedircat1> <filedircat2>
|
16
|
+
diff first catalog from second (<filedircat1> - <filedircat2>)
|
17
|
+
and then print the difference with the format specified on output
|
18
|
+
EOS
|
19
|
+
end
|
20
|
+
|
21
|
+
def opt_parser(options)
|
22
|
+
opt_parser = super(options)
|
23
|
+
opt_parser.on("-f FORMAT", "--fmt FORMAT", "formato") do |v|
|
24
|
+
options.format = v
|
25
|
+
end
|
26
|
+
opt_parser
|
27
|
+
end
|
28
|
+
|
29
|
+
def exec(options, rest)
|
30
|
+
if rest.length < 2
|
31
|
+
puts "you must provide two args (catalogs or directory)"
|
32
|
+
puts "-h to print help"
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
|
36
|
+
cat_filename1 = rest[0]
|
37
|
+
cat_filename2 = rest[1]
|
38
|
+
|
39
|
+
if File.exists?( cat_filename1 )
|
40
|
+
puts "load catalog #{cat_filename1}"
|
41
|
+
s1 = Cat.from_file(cat_filename1)
|
42
|
+
elsif File.directory?(cat_filename1)
|
43
|
+
puts "build first set from directory #{cat_filename1}"
|
44
|
+
s1 = Cat.from_dir(cat_filename1)
|
45
|
+
else
|
46
|
+
puts "#{cat_filename1} is not a catalog file or directory"
|
47
|
+
return 1
|
48
|
+
end
|
49
|
+
|
50
|
+
if File.exists?( cat_filename2 )
|
51
|
+
puts "load catalog #{cat_filename2}"
|
52
|
+
s2 = Cat.from_file(cat_filename2)
|
53
|
+
elsif File.directory?(cat_filename2)
|
54
|
+
puts "build first set from directory #{cat_filename2}"
|
55
|
+
s2 = Cat.from_dir(cat_filename2)
|
56
|
+
else
|
57
|
+
puts "#{cat_filename2} is not a catalog file or directory"
|
58
|
+
return 1
|
59
|
+
end
|
60
|
+
|
61
|
+
puts "build difference"
|
62
|
+
s3 = s1 - s2
|
63
|
+
|
64
|
+
case options.format
|
65
|
+
when "simple"
|
66
|
+
s3.fmt_simple
|
67
|
+
when "ruby"
|
68
|
+
s3.fmt_ruby( "." )
|
69
|
+
else
|
70
|
+
s3.fmt_simple
|
71
|
+
end
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
#module DirCat
|
79
|
+
#
|
80
|
+
# class DirCatDiff
|
81
|
+
#
|
82
|
+
# def self.run
|
83
|
+
# return self.new.parse_args( ARGV )
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def parse_args( args )
|
87
|
+
# options = {}
|
88
|
+
# opts = OptionParser.new
|
89
|
+
# opts.banner =
|
90
|
+
# "Usage: dircat_cfr.rb [options] <filedircat1> <filedircat2>\n\n" +
|
91
|
+
# "fa la differenza fra il primo catalog e il secondo\n" +
|
92
|
+
# "<filedircat1> - <filedircat2>\n" +
|
93
|
+
# "e stampa sull'output con un formato\n"
|
94
|
+
#
|
95
|
+
# opts.on("-h", "--help", "Print this message") do
|
96
|
+
# puts opts
|
97
|
+
# return 0
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
101
|
+
# options[:verbose] = v
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# opts.on("-f FORMAT", "--fmt FORMAT", "formato") do |v|
|
105
|
+
# options[:fmt] = v
|
106
|
+
# end
|
107
|
+
# rest = opts.parse( args )
|
108
|
+
#
|
109
|
+
# # p options
|
110
|
+
# # p ARGV
|
111
|
+
#
|
112
|
+
# if rest.length < 2
|
113
|
+
# puts "you must provide two args (catalogs or directory)"
|
114
|
+
# puts "dircat_cfr -h to print help"
|
115
|
+
# exit
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# cat_filename1 = rest[0]
|
119
|
+
# cat_filename2 = rest[1]
|
120
|
+
#
|
121
|
+
# if File.exists?( cat_filename1 )
|
122
|
+
# puts "load catalog #{cat_filename1}"
|
123
|
+
# s1 = Cat.from_file(cat_filename1)
|
124
|
+
# elsif File.directory?(cat_filename1)
|
125
|
+
# puts "build first set from directory #{cat_filename1}"
|
126
|
+
# s1 = Cat.from_dir(cat_filename1)
|
127
|
+
# else
|
128
|
+
# puts "#{cat_filename1} is not a catalog file or directory"
|
129
|
+
# return 1
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# if File.exists?( cat_filename2 )
|
133
|
+
# puts "load catalog #{cat_filename2}"
|
134
|
+
# s2 = Cat.from_file(cat_filename2)
|
135
|
+
# elsif File.directory?(cat_filename2)
|
136
|
+
# puts "build first set from directory #{cat_filename2}"
|
137
|
+
# s2 = Cat.from_dir(cat_filename2)
|
138
|
+
# else
|
139
|
+
# puts "#{cat_filename2} is not a catalog file or directory"
|
140
|
+
# return 1
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# puts "build difference"
|
144
|
+
# s3 = s1 - s2
|
145
|
+
#
|
146
|
+
# case options[:fmt]
|
147
|
+
# when "simple"
|
148
|
+
# s3.fmt_simple
|
149
|
+
# when "ruby"
|
150
|
+
# s3.fmt_ruby( "." )
|
151
|
+
# else
|
152
|
+
# s3.fmt_simple
|
153
|
+
# end
|
154
|
+
# 0
|
155
|
+
# end
|
156
|
+
# end
|
157
|
+
#end
|
158
|
+
#
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
class CommandQuery < CliCommand
|
4
|
+
|
5
|
+
def self.command
|
6
|
+
"query"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"show info about dircat catalogs"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.usage
|
14
|
+
"Usage: dircat-query [options] <filedircat> [<command>]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def opt_parser(options)
|
18
|
+
opt_parser = super(options)
|
19
|
+
|
20
|
+
opt_parser.on("-o [FILE]", "--output [FILE]", String) do |v|
|
21
|
+
if options[:output]
|
22
|
+
puts "only one file of output can be used"
|
23
|
+
return 1
|
24
|
+
end
|
25
|
+
options.output = v
|
26
|
+
end
|
27
|
+
|
28
|
+
opt_parser.on("-f", "--force", "force write on existent file") do |v|
|
29
|
+
options[:force] = true
|
30
|
+
end
|
31
|
+
|
32
|
+
opt_parser
|
33
|
+
end
|
34
|
+
|
35
|
+
def exec(options, rest)
|
36
|
+
if rest.length < 1
|
37
|
+
puts "missing catalog!"
|
38
|
+
puts "-h to print help"
|
39
|
+
return 0
|
40
|
+
end
|
41
|
+
|
42
|
+
cat_opts = {}
|
43
|
+
cat_filename = rest[0]
|
44
|
+
unless File.exists?(cat_filename)
|
45
|
+
puts "first args must be a catalogue"
|
46
|
+
return 1
|
47
|
+
end
|
48
|
+
|
49
|
+
if rest.length > 1
|
50
|
+
command = rest[1]
|
51
|
+
else
|
52
|
+
command = "report"
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# option verbose
|
57
|
+
#
|
58
|
+
if options.verbose
|
59
|
+
cat_opts[:verbose_level] = 1
|
60
|
+
end
|
61
|
+
|
62
|
+
s = Cat.from_file(cat_filename, cat_opts)
|
63
|
+
|
64
|
+
puts s.send(command.to_sym)
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
#module DirCat
|
72
|
+
#
|
73
|
+
# class DirCatQuery
|
74
|
+
#
|
75
|
+
# def self.run
|
76
|
+
# return self.new.parse_args( ARGV)
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# def parse_args( args )
|
80
|
+
# options = {}
|
81
|
+
# opts = OptionParser.new
|
82
|
+
# opts.banner =
|
83
|
+
# "show info on dircat catalogs\n"
|
84
|
+
#
|
85
|
+
# opts.on("--version", "show the dircat version") do
|
86
|
+
# puts "dircat version #{DirCat::version}"
|
87
|
+
# return 0
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# opts.on("-h", "--help", "Print this message") do
|
91
|
+
# puts opts
|
92
|
+
# return 0
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
96
|
+
# options[:verbose] = v
|
97
|
+
# end
|
98
|
+
#
|
99
|
+
# rest = opts.parse( args )
|
100
|
+
#
|
101
|
+
# # p options
|
102
|
+
# # p ARGV
|
103
|
+
#
|
104
|
+
# if rest.length < 1
|
105
|
+
# puts "missing catalog!"
|
106
|
+
# puts "-h to print help"
|
107
|
+
# return 0
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# cat_opts = {}
|
111
|
+
# cat_filename = rest[0]
|
112
|
+
# unless File.exists?(cat_filename)
|
113
|
+
# puts "first args must be a catalogue"
|
114
|
+
# return 1
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# if rest.length > 1
|
118
|
+
# command = rest[1]
|
119
|
+
# else
|
120
|
+
# command = "report"
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# #
|
124
|
+
# # option verbose
|
125
|
+
# #
|
126
|
+
# if options.has_key?(:verbose)
|
127
|
+
# if options[:verbose]
|
128
|
+
# cat_opts[:verbose_level] = 1
|
129
|
+
# end
|
130
|
+
# end
|
131
|
+
#
|
132
|
+
# s = Cat.from_file( cat_filename, cat_opts )
|
133
|
+
#
|
134
|
+
# puts s.send( command.to_sym )
|
135
|
+
# 0
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
#end
|
data/lib/dircat/entry.rb
CHANGED
data/lib/dircat/extension_md5.rb
CHANGED
data/lib/dircat/report.rb
CHANGED
data/lib/dircat.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
|
-
#
|
3
|
+
# std lib
|
3
4
|
#
|
4
5
|
require 'fileutils'
|
5
6
|
require 'tmpdir'
|
@@ -7,6 +8,11 @@ require 'yaml'
|
|
7
8
|
require 'ostruct'
|
8
9
|
require 'optparse'
|
9
10
|
|
11
|
+
#
|
12
|
+
# rubygems
|
13
|
+
#
|
14
|
+
require 'optparse-command'
|
15
|
+
|
10
16
|
module DirCat
|
11
17
|
def self.version
|
12
18
|
cwd = File.dirname( __FILE__)
|
@@ -25,6 +31,7 @@ require 'dircat/cat'
|
|
25
31
|
require 'dircat/entry'
|
26
32
|
require 'dircat/report'
|
27
33
|
|
28
|
-
require 'dircat/cli/
|
29
|
-
require 'dircat/cli/
|
30
|
-
require 'dircat/cli/
|
34
|
+
require 'dircat/cli/cli_dircat'
|
35
|
+
require 'dircat/cli/command_build'
|
36
|
+
require 'dircat/cli/command_diff'
|
37
|
+
require 'dircat/cli/command_query'
|