Skip to content

Commit 88a186d

Browse files
author
paul
committed
fix set access help message
1 parent 8a52d10 commit 88a186d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

pkg/cli/namespace/set_access.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package clinamespace
22

33
import (
4-
"os"
5-
64
"fmt"
5+
"os"
6+
"sort"
7+
"strings"
78

89
"github.com/containerum/chkit/pkg/cli/prerun"
910
"github.com/containerum/chkit/pkg/context"
1011
"github.com/containerum/chkit/pkg/util/activekit"
11-
"github.com/containerum/chkit/pkg/util/angel"
1212
"github.com/containerum/chkit/pkg/util/coblog"
13+
"github.com/containerum/chkit/pkg/util/text"
1314
"github.com/containerum/kube-client/pkg/model"
1415
"github.com/sirupsen/logrus"
1516
"github.com/spf13/cobra"
@@ -21,12 +22,18 @@ func SetAccess(ctx *context.Context) *cobra.Command {
2122
Aliases: accessAliases,
2223
SuggestFor: accessAliases,
2324
Short: "set namespace access",
24-
Example: "chkit set access $USERNAME $ACCESS_LEVEL [--namespace $ID]",
25-
PreRun: func(cmd *cobra.Command, args []string) {
26-
if err := prerun.PreRun(ctx); err != nil {
27-
angel.Angel(ctx, err)
25+
Long: "Set access level to namespace.\n" +
26+
"Available access levels are:\n" + func() string {
27+
var levels []string
28+
for _, lvl := range model.Levels() {
29+
levels = append(levels, lvl.String())
2830
}
29-
},
31+
sort.Strings(levels)
32+
var lvlsInfo = strings.Join(levels, "\n")
33+
return text.Indent(lvlsInfo, 2)
34+
}(),
35+
Example: "chkit set access $USERNAME $ACCESS_LEVEL [--namespace $ID]",
36+
PreRun: prerun.PreRunFunc(ctx),
3037
Run: func(cmd *cobra.Command, args []string) {
3138
var logger = coblog.Logger(cmd)
3239
if len(args) != 2 {

0 commit comments

Comments
 (0)