package main
import (
"fmt"
"os"
"time"
"github.com/raystack/salt/cli/printer"
)
type Deployment struct {
ID string
Status string
Created time.Time
}
func main() {
// Show info message
printer.Infoln("Starting deployment process...")
fmt.Println()
// Show spinner during operation
spinner := printer.Spin("Preparing deployment")
time.Sleep(1 * time.Second)
spinner.Stop()
// Show success
printer.Successln("Preparation complete")
fmt.Println()
// Deploy multiple services with progress
services := []string{"api", "worker", "frontend", "database"}
bar := printer.Progress(len(services), "Deploying services")
for _, service := range services {
time.Sleep(500 * time.Millisecond)
bar.Add(1)
}
fmt.Println()
// Show results in table
printer.Boldln("Deployment Results")
rows := [][]string{
{"Service", "Status", "Time"},
{"api", printer.Green("Running"), "1.2s"},
{"worker", printer.Green("Running"), "0.8s"},
{"frontend", printer.Green("Running"), "2.1s"},
{"database", printer.Yellow("Starting"), "0.5s"},
}
printer.Table(os.Stdout, rows)
fmt.Println()
// Show structured output
deployment := Deployment{
ID: "deploy-123",
Status: "success",
Created: time.Now(),
}
printer.Boldln("Deployment Details (JSON):")
if err := printer.PrettyJSON(deployment); err != nil {
printer.Errorf("Failed to print JSON: %v\n", err)
os.Exit(1)
}
fmt.Println()
printer.Successf("%s Deployment completed successfully!\n",
printer.Icon("success"))
}