Class: Lhj::Command::Config

Inherits:
Lhj::Command show all
Defined in:
lib/lhj/command/config.rb,
lib/lhj/command/config/info.rb

Overview

config

Direct Known Subclasses

Info, Update

Defined Under Namespace

Classes: Info, Update

Instance Method Summary collapse

Methods inherited from Lhj::Command

#auto_spin, #begin_title, #run, #stop

Constructor Details

#initialize(argv) ⇒ Config

Returns a new instance of Config.



8
9
10
11
# File 'lib/lhj/command/config/info.rb', line 8

def initialize(argv)
  @cli = HighLine.new
  super
end

Instance Method Details

#config_dirObject



29
30
31
# File 'lib/lhj/command/config/info.rb', line 29

def config_dir
  Lhj::Config.instance.home_dir
end

#handleObject



25
26
27
# File 'lib/lhj/command/config/info.rb', line 25

def handle
  show_config
end

#handle_yaml(file) ⇒ Object



21
22
23
# File 'lib/lhj/command/config/info.rb', line 21

def handle_yaml(file)
  '子类实现'
end


33
34
35
36
# File 'lib/lhj/command/config/info.rb', line 33

def print_table(title, table_rows)
  table = Terminal::Table.new title: title, headings: %w[ ], rows: table_rows
  puts table
end

#show_configObject



13
14
15
16
17
18
19
# File 'lib/lhj/command/config/info.rb', line 13

def show_config
  config_arr = Dir.glob("#{config_dir}/**/*.yml")
  config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
  idx = ask_which_one
  config_file = config_arr[idx]
  handle_yaml(config_file)
end