refactor: add progressbar and implement package interface
This commit is contained in:
parent
8dabf244bb
commit
0504d88775
16 changed files with 431 additions and 344 deletions
51
model.go
51
model.go
|
|
@ -3,8 +3,9 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/bubbles/progress"
|
||||
|
|
@ -34,28 +35,38 @@ func (m model) installSpecialSoftware() error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if _, err := exec.LookPath("go"); err == nil {
|
||||
fmt.Println("Go ist bereits installiert.")
|
||||
} else {
|
||||
golangVersion := "1.23.4"
|
||||
if err := downloadGolang(golangVersion); err != nil {
|
||||
return fmt.Errorf("fehler beim Herunterladen von Go: %v", err)
|
||||
}
|
||||
golangCommand := fmt.Sprintf("sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go%s.linux-%s.tar.gz", golangVersion, runtime.GOARCH)
|
||||
if err := installPackage(golangCommand, "", m.sudoPassword); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("rustc"); err == nil {
|
||||
fmt.Println("Rust ist bereits installiert.")
|
||||
} else {
|
||||
rustupCommand := "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y"
|
||||
if err := installPackage(rustupCommand, "", ""); err != nil {
|
||||
return err
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Fehler beim Ermitteln des Home-Verzeichnisses: %v", err)
|
||||
}
|
||||
|
||||
ohMyZshDir := filepath.Join(homeDir, ".oh-my-zsh")
|
||||
if _, err := os.Stat(ohMyZshDir); !os.IsNotExist(err) {
|
||||
fmt.Println("Oh My Zsh ist bereits installiert.")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("Installiere Oh My Zsh...")
|
||||
err = executeShellCommand(`sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"`, "")
|
||||
if err != nil {
|
||||
log.Printf("Fehler bei der Installation von Oh My Zsh: %v\n", err)
|
||||
}
|
||||
|
||||
plugins := []string{
|
||||
"git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions",
|
||||
"git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting",
|
||||
"git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting",
|
||||
"git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autocomplete",
|
||||
}
|
||||
|
||||
for _, plugin := range plugins {
|
||||
err := executeShellCommand(plugin, "")
|
||||
if err != nil {
|
||||
log.Printf("Fehler bei der Installation des Plugins: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Oh My Zsh wurde erfolgreich installiert.")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue