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

Fix-up cmd args #822

Merged
merged 1 commit into from
Mar 14, 2023
Merged
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
9 changes: 2 additions & 7 deletions cmd/tk/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var kubectlContexts = cli.PredictFunc(

func envSetCmd() *cli.Command {
cmd := &cli.Command{
Use: "set",
Use: "set <path>",
Short: "update properties of an environment",
Args: workflowArgs,
Predictors: complete.Flags{
Expand Down Expand Up @@ -234,12 +234,7 @@ func envRemoveCmd() *cli.Command {

func envListCmd() *cli.Command {
args := workflowArgs
args.Validator = cli.ValidateFunc(func(args []string) error {
if len(args) > 1 {
return fmt.Errorf("expects at most 1 arg, received %v", len(args))
}
return nil
})
args.Validator = cli.ArgsRange(0, 1)

cmd := &cli.Command{
Use: "list [<path>]",
Expand Down
7 changes: 1 addition & 6 deletions cmd/tk/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import (

func exportCmd() *cli.Command {
args := workflowArgs
args.Validator = cli.ValidateFunc(func(args []string) error {
if len(args) < 2 {
return fmt.Errorf("expects at least 2 args, received %v", len(args))
}
return nil
})
args.Validator = cli.ArgsMin(2)

cmd := &cli.Command{
Use: "export <outputDir> <path> [<path>...]",
Expand Down
8 changes: 1 addition & 7 deletions cmd/tk/fmt.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"errors"
"fmt"
"io"
"os"
Expand All @@ -21,12 +20,7 @@ func fmtCmd() *cli.Command {
Use: "fmt <FILES|DIRECTORIES>",
Short: "format Jsonnet code",
Args: cli.Args{
Validator: cli.ValidateFunc(func(args []string) error {
if len(args) == 0 {
return errors.New("at least one file or directory is required")
}
return nil
}),
Validator: cli.ArgsMin(1),
Predictor: complete.PredictFiles("*.*sonnet"),
},
}
Expand Down
9 changes: 1 addition & 8 deletions cmd/tk/lint.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"errors"

"github.com/go-clix/cli"
"github.com/gobwas/glob"
"github.com/posener/complete"
Expand All @@ -15,12 +13,7 @@ func lintCmd() *cli.Command {
Use: "lint <FILES|DIRECTORIES>",
Short: "lint Jsonnet code",
Args: cli.Args{
Validator: cli.ValidateFunc(func(args []string) error {
if len(args) == 0 {
return errors.New("at least one file or directory is required")
}
return nil
}),
Validator: cli.ArgsMin(1),
Predictor: complete.PredictFiles("*.*sonnet"),
},
}
Expand Down