Skip to content

Commit

Permalink
rahhh
Browse files Browse the repository at this point in the history
  • Loading branch information
nermalcat69 committed Aug 27, 2024
1 parent e497e9e commit 4405338
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Zerops zCLI
~[Zerops](https://github.com/zeropsio/recipe-shared-assets/blob/main/covers/svg/cover-zcli.svg)

Zerops zCLI is a command line utility for working with [zerops.io](https://zerops.io). It's used
for **CI/CD** development and CLI lovers.
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ func projectCmd() *cmdBuilder.Cmd {
AddChildrenCmd(projectListCmd()).
AddChildrenCmd(projectDeleteCmd()).
AddChildrenCmd(projectServiceImportCmd()).
AddChildrenCmd(projectImportCmd())
AddChildrenCmd(projectImportCmd()).
AddChildrenCmd(projectCreateCmd())
}
45 changes: 45 additions & 0 deletions src/cmd/projectCreate.go
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

View workflow job for this annotation

GitHub Actions / Build && tests for linux amd64

Error return value of `(github.com/zeropsio/zerops-go/sdk.Handler).PostProject` is not checked (errcheck)

Check failure on line 39 in src/cmd/projectCreate.go

View workflow job for this annotation

GitHub Actions / Build && tests for linux 386

Error return value of `(github.com/zeropsio/zerops-go/sdk.Handler).PostProject` is not checked (errcheck)

Check failure on line 39 in src/cmd/projectCreate.go

View workflow job for this annotation

GitHub Actions / Build && tests for darwin amd64

Error return value of `(github.com/zeropsio/zerops-go/sdk.Handler).PostProject` is not checked (errcheck)
Name: cmdData.Project.Name,
})

return nil
})
}

0 comments on commit 4405338

Please sign in to comment.