Class: Flor::Tools::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/flor/tools/shell.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = nil) ⇒ Shell

Returns a new instance of Shell.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/flor/tools/shell.rb', line 15

def initialize(argv=nil)

  env = ENV['FLOR_ENV'] || 'shell'

  @root = File.directory?(env) ? env : "envs/#{env}"

  prepare_home

  over_conf = {}
    #
  c = ENV['FLOR_STO_URI']; over_conf['sto_uri'] = c if c

  @unit = Flor::Unit.new("#{@root}/etc/conf.json", over_conf)

  @unit.conf['unit'] = 'cli'
  #unit.hooker.add('journal', Flor::Journal)

  prepare_db
  prepare_hooks

  @hook = 'on'
  @mute = false
  @paging = true

  if ENV['FLOR_NO_START']
    @unit.check_migration_version
  else
    @unit.start
  end

  @flow_path = File.join(@root, 'home/scratch.flo')
  @ra_flow_path = File.join(@root, 'home/ra_scratch.flo')
  @payload_path = File.join(@root, 'home/payload.json')
  @variables_path = File.join(@root, 'home/variables.json')

  @c = Flor.colours({})

  load_floshrc

  if argv && argv.any?
    do_eval(argv.join(' '))
  else
    print_header
    do_loop
  end
end

Instance Attribute Details

#cObject (readonly)

Returns the value of attribute c.



62
63
64
# File 'lib/flor/tools/shell.rb', line 62

def c
  @c
end

Class Method Details

.is_alias?(c) ⇒ Boolean

Returns:

  • (Boolean)


222
223
224
225
# File 'lib/flor/tools/shell.rb', line 222

def is_alias?(c)

  !! ALIASES.values.find { |a| a.include?(c) }
end

.make_alias(a, b) ⇒ Object



213
214
215
216
217
218
219
220
# File 'lib/flor/tools/shell.rb', line 213

def make_alias(a, b)

  define_method("hlp_#{a}") { "alias to #{b.inspect}" }
  alias_method "man_#{a}", "man_#{b}" rescue nil
  alias_method "cmd_#{a}", "cmd_#{b}"

  (ALIASES[b] ||= []) << a
end