Sha256: c9ed8ebd9a5f0d7dd3b04dbbccae4a960e683de114608ee083a94225f0a1d811

Contents?: true

Size: 874 Bytes

Versions: 5

Compression:

Stored size: 874 Bytes

Contents

module Alf
  module Shell
    class Metadata < Shell::Command(__FILE__, __LINE__)

      options do |opt|

        opt.on_tail('-h', "--help", "Show help") do
          show_help("alf-metadata")
        end

      end

      def run(argv, requester)
        # set requester and parse options
        @requester = requester
        argv = parse_options(argv, :split)

        operand = compile(argv)
        keys    = operand.keys.to_a.map{|k| k.to_a }
        heading = Relation(operand.heading.to_hash.each_pair.map{|k,v|
          {attribute: k, type: v.to_s}
        })
        puts Relation({heading: heading, keys: keys})
      end

      def compile(argv)
        op = operand(argv.shift)
        op.heading
        op
      rescue Alf::NotSupportedError
        op = op.to_relation
        op
      end

    end # class Metadata
  end # module Shell
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-shell-0.16.4 lib/alf/shell/command/metadata.rb
alf-shell-0.16.3 lib/alf/shell/command/metadata.rb
alf-shell-0.16.2 lib/alf/shell/command/metadata.rb
alf-shell-0.16.1 lib/alf/shell/command/metadata.rb
alf-shell-0.16.0 lib/alf/shell/command/metadata.rb