Sha256: 2e34b9be4a01773c4a5c532ab049395aedc249f6992b3f9283c358c7cc5f42da

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

module Alf
  module Shell
    module Support

      AlfFile = ->(arg){
        path = Path(arg)
        path.file? and path.ext =~ /^\.?alf$/
      }

      def connection
        requester && requester.connection
      end

      def operand(arg)
        case arg
        when AlfFile then operand(Path(arg).read)
        when String  then connection.relvar(arg)
        when Array   then operand(arg.first)
        else
          Algebra::Operand.coerce(arg)
        end
      end

      def show_help(who)
        who = "alf-#{who}" if /explain|metadata|show/ =~ who
        if p = Path.backfind("doc/man/#{who}.man")
          exit if system("man #{p}")
          puts Path.backfind("doc/txt/#{who}.txt").read
        else
          puts "Unknown command/operator `#{who}`"
        end
        exit
      end

    end # module Support
  end # module Shell
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-shell-0.15.0 lib/alf/shell/support.rb