9 "github.com/spf13/cobra"
12var runCmd = &cobra.Command{
13 Use: "run [prompt...]",
14 Short: "Run a single non-interactive prompt",
15 Long: `Run a single prompt in non-interactive mode and exit.
16The prompt can be provided as arguments or piped from stdin.`,
19crush run Explain the use of context in Go
21# Pipe input from stdin
22curl https://charm.land | crush run "Summarize this website"
25crush run "What is this code doing?" <<< prrr.go
27# Run in quiet mode (hide the spinner)
28crush run --quiet "Generate a README for this project"
30 RunE: func(cmd *cobra.Command, args []string) error {
31 quiet, _ := cmd.Flags().GetBool("quiet")
33 app, err := setupApp(cmd)
39 if !app.Config().IsConfigured() {
40 return fmt.Errorf("no providers configured - please run 'crush' to set up a provider interactively")
43 prompt := strings.Join(args, " ")
45 prompt, err = MaybePrependStdin(prompt)
47 slog.Error("Failed to read from stdin", "error", err)
52 return fmt.Errorf("no prompt provided")
55 // TODO: Make this work when redirected to something other than stdout.
57 // crush run "Do something fancy" > output.txt
58 // echo "Do something fancy" | crush run > output.txt
60 // TODO: We currently need to press ^c twice to cancel. Fix that.
61 return app.RunNonInteractive(cmd.Context(), os.Stdout, prompt, quiet)
66 runCmd.Flags().BoolP("quiet", "q", false, "Hide spinner")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list