(deps commandDeps)
| 52 | } |
| 53 | |
| 54 | func newDaemonStartCommand(deps commandDeps) *cobra.Command { |
| 55 | var ( |
| 56 | foreground bool |
| 57 | internalChild bool |
| 58 | ) |
| 59 | |
| 60 | cmd := &cobra.Command{ |
| 61 | Use: daemonStartKey, |
| 62 | Short: "Start the AGH daemon", |
| 63 | Example: ` # Start AGH in the background and wait for readiness |
| 64 | agh daemon start |
| 65 | |
| 66 | # Keep logs attached to the current terminal |
| 67 | agh daemon start --foreground`, |
| 68 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 69 | if foreground || internalChild { |
| 70 | return runDaemonForeground(cmd.Context(), deps) |
| 71 | } |
| 72 | status, err := runDaemonDetached(cmd.Context(), deps) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | return writeCommandOutput(cmd, daemonStatusBundle(status, deps.now)) |
| 77 | }, |
| 78 | } |
| 79 | cmd.Flags().BoolVar(&foreground, "foreground", false, "Run the daemon in the foreground") |
| 80 | cmd.Flags().BoolVar(&internalChild, internalChildFlagName, false, "Internal detached child mode") |
| 81 | mustMarkFlagHidden(cmd, internalChildFlagName) |
| 82 | return cmd |
| 83 | } |
| 84 | |
| 85 | func newDaemonRelaunchCommand(deps commandDeps) *cobra.Command { |
| 86 | return &cobra.Command{ |
no test coverage detected