feat: Add Cloud Endpoint Sync Commands (#216)

* feat: Add cloud sync command

* feat: Add pmg cloud commands

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes
This commit is contained in:
Abhisek Datta
2026-04-13 13:40:18 +05:30
committed by GitHub
parent e67735c1c3
commit 887984612c
14 changed files with 453 additions and 92 deletions
+46
View File
@@ -9,6 +9,7 @@ import (
"github.com/safedep/pmg/analyzer"
"github.com/safedep/pmg/internal/models"
"golang.org/x/term"
)
// The UI is internal to PMG and opinionated for the CLI.
@@ -135,6 +136,51 @@ func ShowWarning(message string) {
fmt.Fprintf(os.Stderr, "PMG: %s\n", Colors.Red(message))
}
// Infof prints an informational message, suppressed in silent mode.
func Infof(msg string, args ...interface{}) {
if verbosityLevel == VerbosityLevelSilent {
return
}
fmt.Println(fmt.Sprintf(msg, args...))
}
// Successf prints a green success message, suppressed in silent mode.
func Successf(msg string, args ...interface{}) {
if verbosityLevel == VerbosityLevelSilent {
return
}
fmt.Printf("%s %s\n", Colors.Green("✓"), fmt.Sprintf(msg, args...))
}
// PromptInput prints a label and reads a line of visible input from stdin.
func PromptInput(label string) (string, error) {
fmt.Printf("%s %s", Colors.Cyan(""), Colors.Bold(label))
scanner := bufio.NewScanner(os.Stdin)
if scanner.Scan() {
return strings.TrimSpace(scanner.Text()), nil
}
if err := scanner.Err(); err != nil {
return "", err
}
return "", fmt.Errorf("no input received")
}
// PromptSecret prints a label and reads input from stdin with echo disabled.
// Returns an error if stdin is not a terminal (e.g. piped input).
func PromptSecret(label string) (string, error) {
if !term.IsTerminal(int(os.Stdin.Fd())) {
return "", fmt.Errorf("interactive terminal required for secure input")
}
fmt.Printf("%s %s", Colors.Cyan("▪"), Colors.Bold(label))
raw, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println() // newline after hidden input
if err != nil {
return "", err
}
return strings.TrimSpace(string(raw)), nil
}
func Fatalf(msg string, args ...interface{}) {
ClearStatus()