-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.go
71 lines (60 loc) · 1.76 KB
/
install.go
1
2
3
4
5
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
"log"
)
var installCmd = &cobra.Command{
Use: "install",
Short: "Установить инструменты для выбранного стека",
Run: installRun,
}
func installRun(cmd *cobra.Command, args []string) {
osType := detectOS()
fmt.Printf("Обнаруженная ОС: %s\n", osType)
stackStr := selectStack()
stack := StringToStack(stackStr)
ide := selectIDE(stack)
additionalTools := selectStackTools(stackStr)
err := installStack(stack, ide, additionalTools, osType)
if err != nil {
fmt.Printf("Ошибка установки: %v\n", err)
} else {
fmt.Println("Установка завершена успешно.")
}
}
func selectIDE(stack Stack) []string {
var options []string
switch stack {
case FrontendStack:
options = []string{"Visual Studio Code", "WebStorm", "Sublime Text"}
case JavaKotlinStack:
options = []string{"IntelliJ IDEA", "Eclipse", "NetBeans"}
case GolangStack:
options = []string{"Visual Studio Code", "GoLand", "Sublime Text"}
case PythonStack:
options = []string{"PyCharm", "Visual Studio Code", "Sublime Text"}
default:
options = []string{"Visual Studio Code", "Sublime Text"}
}
prompt := promptui.Select{
Label: "Выберите IDE",
Items: append([]string{"[Выбрать все]"}, options...),
Size: len(options) + 1,
Templates: &promptui.SelectTemplates{
Label: "{{ . }}",
Active: "\u25B6 {{ . | cyan }}",
Inactive: " {{ . }}",
Selected: "\u2714 {{ . | green }}",
},
}
_, result, err := prompt.Run()
if err != nil {
log.Fatalf("Ошибка при выборе IDE: %v", err)
}
if result == "[Выбрать все]" {
return options
}
return []string{result}
}