8000 Refactor setup command logic by Apdul0329 · Pull Request #82 · alpacanetworks/alpamon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor setup command logic #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmd/alpamon/command/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package setup

import (
"fmt"
cli "github.com/alpacanetworks/alpacon-cli/utils"
"github.com/alpacanetworks/alpamon/pkg/utils"
"github.com/spf13/cobra"
"golang.org/x/term"
"os"
"os/exec"
"path/filepath"
"syscall"
"text/template"

cli "github.com/alpacanetworks/alpacon-cli/utils"
"github.com/alpacanetworks/alpamon/pkg/utils"
"github.com/spf13/cobra"
"golang.org/x/term"
)

var (
Expand Down Expand Up @@ -43,8 +44,14 @@ var SetupCmd = &cobra.Command{
var isOverwrite bool
configExists := fileExists(configTarget)

if configExists && term.IsTerminal(syscall.Stdin) {
if configExists {
fmt.Println("A configuration file already exists at:", configTarget)
fmt.Println("When setting up non-interactively, the existing configuration file will be used.")

if !term.IsTerminal(syscall.Stdin) {
return nil
}

isOverwrite = cli.PromptForBool("Do you want to overwrite it with a new configuration?: ")
if !isOverwrite {
fmt.Println("Keeping the existing configuration file. Skipping configuration update.")
Expand Down
Loading
0