-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e497e9e
commit 4405338
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/zeropsio/zcli/src/cmd/scope" | ||
"github.com/zeropsio/zcli/src/cmdBuilder" | ||
"github.com/zeropsio/zcli/src/i18n" | ||
"github.com/zeropsio/zcli/src/uxHelpers" | ||
"github.com/zeropsio/zerops-go/dto/input/body" | ||
"github.com/zeropsio/zerops-go/sdk" | ||
) | ||
|
||
func projectCreateCmd() *cmdBuilder.Cmd { | ||
return cmdBuilder.NewCmd(). | ||
Use("create"). | ||
Short(i18n.T(i18n.CmdDescProjectCreate)). | ||
ScopeLevel(scope.Project). | ||
Arg(scope.ProjectArgName, cmdBuilder.OptionalArg()). | ||
BoolFlag("confirm", false, i18n.T(i18n.ConfirmFlag)). | ||
HelpFlag(i18n.T(i18n.CmdHelpProjectCreate)). | ||
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error { | ||
if !cmdData.Params.GetBool("confirm") { | ||
confirmed, err := uxHelpers.YesNoPrompt( | ||
ctx, | ||
cmdData.UxBlocks, | ||
i18n.T(i18n.ProjectCreateConfirm, cmdData.Project.Name), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
if !confirmed { | ||
return errors.New(i18n.T(i18n.DestructiveOperationConfirmationFailed)) | ||
} | ||
} | ||
|
||
sdk.Handler{}.PostProject(ctx, body.PostProject{ | ||
Check failure on line 39 in src/cmd/projectCreate.go GitHub Actions / Build && tests for linux amd64
Check failure on line 39 in src/cmd/projectCreate.go GitHub Actions / Build && tests for linux 386
|
||
Name: cmdData.Project.Name, | ||
}) | ||
|
||
return nil | ||
}) | ||
} |