First commit of golang CLI.
This commit is contained in:
38
wild-cli/cmd/wild/main.go
Normal file
38
wild-cli/cmd/wild/main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/wild-cloud/wild-cli/internal/output"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Set up context with cancellation for graceful shutdown
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Handle interrupt signals gracefully
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigChan
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
// Initialize output logger
|
||||
logger := output.NewLogger()
|
||||
defer func() {
|
||||
_ = logger.Sync() // Ignore sync errors on program exit
|
||||
}()
|
||||
|
||||
// Execute root command
|
||||
cmd := newRootCommand()
|
||||
if err := cmd.ExecuteContext(ctx); err != nil {
|
||||
logger.Error("Command execution failed", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user