14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/organo/commands/remote/remote_remove.rb', line 14
def call(env:, **)
if File.exist?('./.organo')
config = File.exist?(Config::DEFAULT_FILE) ? JSON.parse(File.read(Config::DEFAULT_FILE)) : nil
unless config.nil?
section = config.find { |option| option['section'] == 'remotes' }
if !section.nil?
index = section['entries'].find_index { |entry| entry['env'] == env }
if index.nil?
puts 'Specified environment does not exist'
elsif !section['entries'].delete_at(index).nil?
puts "Removed \"#{env}\" entry"
end
else
puts 'Configuration file does not have a remote'
end
end
File.write(Config::DEFAULT_FILE, JSON.pretty_generate(config))
else
puts 'This directory is not initialized.'
puts 'Run command `organo init` to create the configuration directory.'
end
end
|