Class: DirCat::CommandQuery
- Inherits:
-
OptParseCommand::Command
- Object
- OptParseCommand::Command
- DirCat::CommandQuery
- Defined in:
- lib/dircat/cat_on_yaml_cli/command_query.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.command ⇒ Object
7 8 9 |
# File 'lib/dircat/cat_on_yaml_cli/command_query.rb', line 7 def self.command "query" end |
.description ⇒ Object
11 12 13 |
# File 'lib/dircat/cat_on_yaml_cli/command_query.rb', line 11 def self.description "show info about dircat catalogs" end |
.usage ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dircat/cat_on_yaml_cli/command_query.rb', line 15 def self.usage <<-EOS Usage: query [options] <catalog> [<method>] where method can be: report: show info on catalog duplicates: list duplicates into catalog list_dup script_dup fmt_simple EOS end |
Instance Method Details
#exec(main, options, rest) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/dircat/cat_on_yaml_cli/command_query.rb', line 28 def exec(main, , rest) if rest.length < 1 puts "missing catalog!" puts "-h to print help" return 0 end cat_opts = {} cat_filename = rest[0] if !File.exists?(cat_filename) or File.directory?(cat_filename) puts "first args must be a catalogue" return 1 end if rest.length > 1 command = rest[1] else command = "report" end # # option verbose # if .verbose cat_opts[:verbose_level] = 1 end begin s = CatOnYaml.from_file(cat_filename, cat_opts) rescue Exception => e $stderr.put "cannot read catalog '#{cat_filename}' maybe it is an old version?" return false end if s.respond_to? command.to_sym puts s.send(command.to_sym) true else puts "unknow methods '#{command}'" false end end |