Class: Lhj::Command::Config::Info
- Inherits:
-
Lhj::Command::Config
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::Config
- Lhj::Command::Config::Info
- Defined in:
- lib/lhj/command/config/info.rb
Overview
show config info
Instance Method Summary collapse
Methods inherited from Lhj::Command::Config
#config_dir, #handle, #initialize, #print_table, #show_config
Methods inherited from Lhj::Command
#auto_spin, #begin_title, #handle, #initialize, #run, #stop
Constructor Details
This class inherits a constructor from Lhj::Command::Config
Instance Method Details
#ask_which_one ⇒ Object
67 68 69 |
# File 'lib/lhj/command/config/info.rb', line 67 def ask_which_one @cli.ask('查看哪个配置: '.green).strip.to_i end |
#handle_yaml(file) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lhj/command/config/info.rb', line 43 def handle_yaml(file) table_rows = [] content = YAML.load_file(file) case content when Array content.each do |row| next unless row.is_a?(Hash) row.each do |key, value| table_rows << [key, value] end table_rows << :separator end when Hash content.each do |key, value| table_rows << [key, value] end end title = File.basename(file).to_s print_table(title, table_rows) if table_rows.count.positive? end |