Module: Alf::Shell::Support

Included in:
Main
Defined in:
lib/alf/shell/support.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#connectionObject



10
11
12
# File 'lib/alf/shell/support.rb', line 10

def connection
  requester && requester.connection
end

#operand(arg) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/alf/shell/support.rb', line 14

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

#show_help(who) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/alf/shell/support.rb', line 24

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