on main help sign in
chore: send `interactive` attribute (for `crush run`) (#1635)
0d0ac7cAndrey Nering
internal/cmd/run.go+7
@@ -8,6 +8,7 @@ import (
8 "os/signal"
8 "os/signal"
9 "strings"
9 "strings"
10
10
11+ "github.com/charmbracelet/crush/internal/event"
11 "github.com/spf13/cobra"
12 "github.com/spf13/cobra"
12)
13)
13
14
@@ -58,8 +59,14 @@ crush run --quiet "Generate a README for this project"
58 return fmt.Errorf("no prompt provided")
59 return fmt.Errorf("no prompt provided")
59 }
60 }
60
61
62+ event.SetInteractive(true)
63+ event.AppInitialized()
64+
61 return app.RunNonInteractive(ctx, os.Stdout, prompt, quiet)
65 return app.RunNonInteractive(ctx, os.Stdout, prompt, quiet)
62 },
66 },
67+ PostRun: func(cmd *cobra.Command, args []string) {
68+ event.AppExited()
69+ },
63}
70}
64
71
65func init() {
72func init() {
internal/event/event.go+6−1
@@ -26,9 +26,14 @@ var (
26 Set("TERM", os.Getenv("TERM")).
26 Set("TERM", os.Getenv("TERM")).
27 Set("SHELL", filepath.Base(os.Getenv("SHELL"))).
27 Set("SHELL", filepath.Base(os.Getenv("SHELL"))).
28 Set("Version", version.Version).
28 Set("Version", version.Version).
29− Set("GoVersion", runtime.Version())
29+ Set("GoVersion", runtime.Version()).
30+ Set("Interactive", false)
30)
31)
31
32
33+func SetInteractive(interactive bool) {
34+ baseProps = baseProps.Set("interactive", interactive)
35+}
36+
32func Init() {
37func Init() {
33 c, err := posthog.NewWithConfig(key, posthog.Config{
38 c, err := posthog.NewWithConfig(key, posthog.Config{
34 Endpoint: endpoint,
39 Endpoint: endpoint,