Sha256: 3942fd824121cdd73154b48888b3e20a16c61e57a11b578c07f3308579249407

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

# -*- coding: utf-8 -*-

class CommandQuery < OptParseCommand::CliCommand

  def self.command
    "query"
  end

  def self.description
    "show info about dircat catalogs"
  end

  def self.usage
    "Usage: query [options] <catalog> [<method>]"
  end

  def exec(options, 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 options.verbose
      cat_opts[:verbose_level] = 1
    end

    s = Cat.from_file(cat_filename, cat_opts)

    puts s.send(command.to_sym)
    true
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dircat-0.1.7 lib/dircat/cli/command_query.rb
dircat-0.1.6 lib/dircat/cli/command_query.rb