Skip to content

Commit bbf2931

Browse files
author
Satish Ramachandran
committed
Incorporate review comment for CLI
1 parent 37f1cef commit bbf2931

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

netctl/commands.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ var Commands = []cli.Command{
5151
ArgsUsage: "[network] [group]",
5252
Flags: []cli.Flag{
5353
tenantFlag,
54-
cli.StringFlag{
54+
cli.StringSliceFlag{
5555
Name: "policy, p",
56-
Usage: "Policy List (separated by commas)",
56+
Usage: "Policy",
5757
},
58-
cli.StringFlag{
59-
Name: "external-contracts, e",
60-
Usage: "External contracts(separated by commas)",
58+
cli.StringSliceFlag{
59+
Name: "external-contract, e",
60+
Usage: "External contract",
6161
},
6262
},
6363
Action: createEndpointGroup,
@@ -291,9 +291,9 @@ var Commands = []cli.Command{
291291
Name: "provided, p",
292292
Usage: "External contracts type - provided",
293293
},
294-
cli.StringFlag{
295-
Name: "contracts, a",
296-
Usage: "Contracts (separated by commas)",
294+
cli.StringSliceFlag{
295+
Name: "contract, a",
296+
Usage: "Contract",
297297
},
298298
},
299299
Action: createExternalContracts,

netctl/netctl.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,9 @@ func createEndpointGroup(ctx *cli.Context) {
396396
network := ctx.Args()[0]
397397
group := ctx.Args()[1]
398398

399-
policies := strings.Split(ctx.String("policy"), ",")
400-
if ctx.String("policy") == "" {
401-
policies = []string{}
402-
}
399+
policies := ctx.StringSlice("policy")
403400

404-
extContractsGrps := strings.Split(ctx.String("external-contracts"), ",")
405-
if ctx.String("external-contracts") == "" {
406-
extContractsGrps = []string{}
407-
}
401+
extContractsGrps := ctx.StringSlice("external-contract")
408402

409403
errCheck(ctx, getClient(ctx).EndpointGroupPost(&contivClient.EndpointGroup{
410404
TenantName: tenant,
@@ -865,8 +859,8 @@ func createExternalContracts(ctx *cli.Context) {
865859

866860
tenant := ctx.String("tenant")
867861

868-
contracts := strings.Split(ctx.String("contracts"), ",")
869-
if ctx.String("contracts") == "" {
862+
contracts := ctx.StringSlice("contracts")
863+
if len(contracts) == 0 {
870864
errExit(ctx, exitHelp, "Contracts not provided", false)
871865
}
872866

0 commit comments

Comments
 (0)