Skip to content

Commit

Permalink
port_set: Add accepted parameters in help output
Browse files Browse the repository at this point in the history
+go fmt
  • Loading branch information
davidk committed Jul 16, 2023
1 parent 9de251c commit 6e54d68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 7 additions & 7 deletions port_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ type PortSettingCommand struct {
Address string `required:"" help:"the Netgear switch's IP address or host name to connect to" short:"a"`
Ports []int `required:"" help:"port number (starting with 1), use multiple times for setting multiple ports at once" short:"p" name:"port"`
Name string `optional:"" help:"sets the name of a port, 1-16 character limit" short:"n"`
Speed string `optional:"" help:"set the speed and duplex of the port" short:"s"`
IngressRateLimit string `optional:"" help:"set an incoming rate limit for the port" short:"i"`
EgressRateLimit string `optional:"" help:"set an outgoing rate limit for the port" short:"o"`
FlowControl string `optional:"" help:"enable/disable flow control on port"`
Speed string `optional:"" help:"set the speed and duplex of the port ['100M full', '100M half', '10M full', '10M half', 'Auto', 'Disable']" short:"s"`
IngressRateLimit string `optional:"" help:"set an incoming rate limit for the port ['1 Mbit/s', '128 Mbit/s', '16 Mbit/s', '2 Mbit/s', '256 Mbit/s', '32 Mbit/s', '4 Mbit/s', '512 Kbit/s', '512 Mbit/s', '64 Mbit/s', '8 Mbit/s', 'No Limit']" short:"i"`
EgressRateLimit string `optional:"" help:"set an outgoing rate limit for the port ['1 Mbit/s', '128 Mbit/s', '16 Mbit/s', '2 Mbit/s', '256 Mbit/s', '32 Mbit/s', '4 Mbit/s', '512 Kbit/s', '512 Mbit/s', '64 Mbit/s', '8 Mbit/s', 'No Limit']" short:"o"`
FlowControl string `optional:"" help:"enable/disable flow control on port ['Off', 'On']"`
}

func (portSet *PortSettingCommand) Run(args *GlobalOptions) error {
Expand Down Expand Up @@ -138,19 +138,19 @@ func comparePortSettings(name Setting, defaultValue string, newValue string) (st
case Speed:
speed := bidiMapLookup(newValue, portSpeedMap)
if speed == "unknown" {
return speed, errors.New("port speed could not be set. Accepted vaules are: " + valuesAsString(portSpeedMap))
return speed, errors.New("port speed could not be set. Accepted values are: " + valuesAsString(portSpeedMap))
}
return speed, nil
case IngressRateLimit:
inRateLimit := bidiMapLookup(newValue, portRateLimitMap)
if inRateLimit == "unknown" {
return inRateLimit, errors.New("ingress rate limit could not be set. Accepted vaules are: " + valuesAsString(portRateLimitMap))
return inRateLimit, errors.New("ingress rate limit could not be set. Accepted values are: " + valuesAsString(portRateLimitMap))
}
return inRateLimit, nil
case EgressRateLimit:
outRateLimit := bidiMapLookup(newValue, portRateLimitMap)
if outRateLimit == "unknown" {
return outRateLimit, errors.New("ingress rate limit could not be set. Accepted vaules are: " + valuesAsString(portRateLimitMap))
return outRateLimit, errors.New("ingress rate limit could not be set. Accepted values are: " + valuesAsString(portRateLimitMap))
}
return outRateLimit, nil
case FlowControl:
Expand Down
5 changes: 3 additions & 2 deletions port_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
_ "embed"
"github.com/corbym/gocrest/is"
"github.com/corbym/gocrest/then"
"strings"
"testing"

"github.com/corbym/gocrest/is"
"github.com/corbym/gocrest/then"
)

func TestFindHashInPortHtml(t *testing.T) {
Expand Down

0 comments on commit 6e54d68

Please sign in to comment.