6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/dev_context/commands/init.rb', line 6
def cmd_init
explicit_impl = argv.shift
return usage_error("dx init [ruby|go|elixir]") unless argv.empty?
if explicit_impl && !valid_impl?(explicit_impl)
err.puts("dx: unknown implementation '#{explicit_impl}'")
return usage_error("dx init [ruby|go|elixir]")
end
created = config.init!
shell_status = ShellSetup.new.install!
out.puts(created ? "Initialized ~/.dxcf" : "~/.dxcf already exists")
shell_message = case shell_status
when :created then "Created ~/.dx.sh"
when :updated then "Updated ~/.dx.sh"
else "~/.dx.sh already exists"
end
out.puts(shell_message)
out.puts('Add `source ~/.dx.sh` to ~/.zshrc or ~/.bashrc')
impl = if explicit_impl
explicit_impl.downcase
elsif stdin.tty?
prompt_dx_impl
end
if impl
updated_files = persist_dx_impl_choice(impl)
out.puts("Set DX_IMPL=#{impl} in #{updated_files.join(', ')}")
end
0
end
|