package main

import (
	"fmt"
	"os/exec"

	ctoai "github.com/cto-ai/sdk-go/v2"
)

func main() {
	client := ctoai.NewClient()

	repo, err := client.Prompt.Input("repo", "Which application do you want to deploy?", ctoai.OptInputAllowEmpty(false))
	if err != nil {
		panic(err)
	}

  cmd := exec.Command("ls", "-asl")
  stdout, err := cmd.Output()
  if err != nil {
    panic(err.Error())
  }

  err = client.Sdk.Log(string(stdout))
	if err != nil {
		panic(err)
	}

	err = client.Sdk.Log("\nHere is how you can send logs\n")
	if err != nil {
		panic(err)
	}

	err = client.Ux.Print(fmt.Sprintf("🚀 %s's successful deployment has been recorded!", repo))
	if err != nil {
		panic(err)
	}

	event := map[string]interface{}{
		"event_name":   "deployment",
		"event_action": "succeeded",
		"branch":       "main",
		"repo":         repo,
	}

	err = client.Sdk.Track([]string{}, "", event)
	if err != nil {
		panic(err)
	}
}
