This adds more logging in certain places, and adds logging to the CLI. It also allows for certain commands in the CLI to be used without a daemon connection, namely `init`, which previously required the daemon to be connected, but now does not since it doesnt need it.
26 lines
667 B
Go
26 lines
667 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
util "github.com/juls0730/flux/internal/util/cli"
|
|
)
|
|
|
|
func StartCommand(ctx CommandCtx, args []string) error {
|
|
projectName, err := util.GetProject("start", args, ctx.Config, ctx.Logger)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Put request to start the project, since the start endpoint is idempotent.
|
|
// If the project is already running, this will return a 304 Not Modified
|
|
err = util.PutRequest(ctx.Config.DaemonURL+"/app/"+projectName.Id+"/start", nil, ctx.Logger)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to start %s: %v", projectName.Name, err)
|
|
}
|
|
|
|
fmt.Printf("Successfully started %s\n", projectName.Name)
|
|
|
|
return nil
|
|
}
|