Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed extra args in cmds #295

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/harbor/root/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package root
import (
"github.com/goharbor/harbor-cli/pkg/api"
"github.com/goharbor/harbor-cli/pkg/views/health"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

func HealthCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "health",
Short: "Get the health status of Harbor components",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
RunE: func(cmd *cobra.Command, args []string) error {
status, err := api.GetHealth()
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion cmd/harbor/root/labels/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ func CreateLabelCommand() *cobra.Command {
Short: "create label",
Long: "create label in harbor",
Example: "harbor label create",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
var err error
createView := &create.CreateView{
Expand Down
5 changes: 5 additions & 0 deletions cmd/harbor/root/labels/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func ListLabelCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "list labels",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
label, err := api.ListLabel(opts)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions cmd/harbor/root/project/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func ListProjectCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "list project",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
if private && public {
log.Fatal("Cannot specify both --private and --public flags")
Expand Down
6 changes: 5 additions & 1 deletion cmd/harbor/root/registry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ func CreateRegistryCommand() *cobra.Command {
Use: "create",
Short: "create registry",
Example: "harbor registry create",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
var err error
createView := &api.CreateRegView{
Expand Down
5 changes: 5 additions & 0 deletions cmd/harbor/root/registry/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ func ListRegistryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "list registry",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
registry, err := api.ListRegistries(opts)

Expand Down
5 changes: 5 additions & 0 deletions cmd/harbor/root/schedule/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func ListScheduleCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "show all schedule jobs in Harbor",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
schedule, err := api.ListSchedule(opts)

Expand Down
6 changes: 5 additions & 1 deletion cmd/harbor/root/user/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ func UserCreateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "create user",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Run: func(cmd *cobra.Command, args []string) {
var err error
createView := &create.CreateView{
Expand Down
10 changes: 7 additions & 3 deletions cmd/harbor/root/user/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ func UserListCmd() *cobra.Command {
var opts api.ListFlags

cmd := &cobra.Command{
Use: "list",
Short: "list users",
Args: cobra.NoArgs,
Use: "list",
Short: "list users",
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
Aliases: []string{"ls"},
Run: func(cmd *cobra.Command, args []string) {
response, err := api.ListUsers(opts)
Expand Down
6 changes: 6 additions & 0 deletions cmd/harbor/root/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/goharbor/harbor-cli/cmd/harbor/internal/version"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -15,6 +16,11 @@ func versionCommand() *cobra.Command {
Short: "Version of Harbor CLI",
Long: `Get Harbor CLI version, git commit, go version, build time, release channel, os/arch, etc.`,
Example: ` harbor version`,
PreRun: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
log.Fatalf("Error: accepts 0 arg(s), received %d: %v", len(args), args)
}
},
RunE: func(cmd *cobra.Command, args []string) error {
return runVersion()
},
Expand Down
Loading