Sha256: ea3c5b57791dc58869584cd696dbb370e9c1a3dbb374af5b9551b257f9fc3cf9

Contents?: true

Size: 882 Bytes

Versions: 5

Compression:

Stored size: 882 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|repl/ =~ 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

5 entries across 5 versions & 1 rubygems

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