class Chid::Commands::Init
Public Instance Methods
run()
click to toggle source
# File lib/chid/commands/init.rb, line 21 def run create_or_update_chid_config_file end
Private Instance Methods
base_configurations()
click to toggle source
# File lib/chid/commands/init.rb, line 58 def base_configurations { chid: { workstations: {}, tmux_templates: {} } } end
chid_config_file_exist?()
click to toggle source
# File lib/chid/commands/init.rb, line 67 def chid_config_file_exist? File.exist?(chid_config_path) end
chid_config_path()
click to toggle source
# File lib/chid/commands/init.rb, line 26 def chid_config_path @chid_config_path ||= ::ChidConfig.new.chid_config_path end
chid_configurations()
click to toggle source
# File lib/chid/commands/init.rb, line 49 def chid_configurations return base_configurations unless chid_config_file_exist? data = YAML.load_file chid_config_path data[:chid][:workstations] = data[:chid].fetch(:workstations, {}) data[:chid][:tmux_templates] = data[:chid].fetch(:tmux_templates, {}) data end
create_or_update_chid_config_file()
click to toggle source
# File lib/chid/commands/init.rb, line 30 def create_or_update_chid_config_file print_informations dump_on_chid_config_file(chid_configurations) end
dump_on_chid_config_file(configurations)
click to toggle source
# File lib/chid/commands/init.rb, line 43 def dump_on_chid_config_file(configurations) File.open(chid_config_path, 'w') do |file| YAML.dump(configurations, file) end end
print_informations()
click to toggle source
# File lib/chid/commands/init.rb, line 35 def print_informations print "\n--- Installing chid ---\n " print "\nCreating the " unless chid_config_file_exist? print "\nUpdating the " if chid_config_file_exist? print "~/.chid.config ".blue print "file\n" end