Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit 4e51a3f

Browse files
committed
refactor: Use standardized host:port and configuration file flags
1 parent e68164f commit 4e51a3f

File tree

9 files changed

+14
-12
lines changed

9 files changed

+14
-12
lines changed

cmd/constants.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package cmd
22

33
const (
4-
DHCPDDHostPortDefault = "localhost:1240" // DHCPDDHostPortDefault is the default Host:port of `dhcpdd`.
5-
DHClientDHostPortDefault = "localhost:1241" // DHClientDHostPortDefault is the default Host:port of `dhclient`.
4+
DHCPDDHostPortDefault = "localhost:1240" // DHCPDDHostPortDefault is the default Host:port of `dhcpdd`.
5+
DHClientDHostPortDefault = "localhost:1241" // DHClientDHostPortDefault is the default Host:port of `dhclient`.
6+
HostPortDocs = "Host:port of the server to use." // HostPortDocs is the documentation for the host:port flag.
7+
ConfigurationFileDocs = "Configuration file to use." // ConfigurationFileDocs is the documentation for the configuration file flag.)
68
)
79

810
const (

cmd/dhclientctl/cmd/apply.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func init() {
5656
deviceFlag string
5757
)
5858

59-
applyCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, "Host:port of the dhclientd server to use.")
60-
applyCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, "Configuration file to use.")
59+
applyCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, constants.HostPortDocs)
60+
applyCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, constants.ConfigurationFileDocs)
6161
applyCmd.PersistentFlags().StringVarP(&deviceFlag, deviceKey, "d", "edge1", "Device to bind to.")
6262

6363
if err := viper.BindPFlags(applyCmd.PersistentFlags()); err != nil {

cmd/dhclientctl/cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func init() {
6464
serverHostPortFlag string
6565
)
6666

67-
deleteCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, "Host:port of the go-isc-dhcp server to use.")
67+
deleteCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, constants.HostPortDocs)
6868

6969
if err := viper.BindPFlags(deleteCmd.PersistentFlags()); err != nil {
7070
log.Fatal(constants.CouldNotBindFlagsErrorMessage, rz.Err(err))

cmd/dhclientctl/cmd/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func init() {
7575
serverHostPortFlag string
7676
)
7777

78-
getCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, "Host:port of the go-isc-dhcp server to use.")
78+
getCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHClientDHostPortDefault, constants.HostPortDocs)
7979

8080
if err := viper.BindPFlags(getCmd.PersistentFlags()); err != nil {
8181
log.Fatal(constants.CouldNotBindFlagsErrorMessage, rz.Err(err))

cmd/dhclientd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func init() {
117117
hostPortFlag string
118118
)
119119

120-
rootCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, "Configuration file to use.")
120+
rootCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, constants.ConfigurationFileDocs)
121121
rootCmd.PersistentFlags().StringVarP(&hostPortFlag, listenHostPortKey, "l", constants.DHClientDHostPortDefault, "TCP listen host:port.")
122122

123123
if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {

cmd/dhcpdctl/cmd/apply.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func init() {
6969
subnetsFlag string
7070
)
7171

72-
applyCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, "Host:port of the dhcpdd server to use.")
73-
applyCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, "Configuration file to use.")
72+
applyCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, constants.HostPortDocs)
73+
applyCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, constants.ConfigurationFileDocs)
7474
applyCmd.PersistentFlags().StringVarP(&deviceFlag, deviceKey, "d", "edge0", "Device to bind to.")
7575
applyCmd.PersistentFlags().StringVarP(&subnetsFlag, subnetsKey, "n", `[
7676
{

cmd/dhcpdctl/cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func init() {
6464
serverHostPortFlag string
6565
)
6666

67-
deleteCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, "Host:port of the go-isc-dhcp server to use.")
67+
deleteCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, constants.HostPortDocs)
6868

6969
if err := viper.BindPFlags(deleteCmd.PersistentFlags()); err != nil {
7070
log.Fatal(constants.CouldNotBindFlagsErrorMessage, rz.Err(err))

cmd/dhcpdctl/cmd/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func init() {
7575
serverHostPortFlag string
7676
)
7777

78-
getCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, "Host:port of the go-isc-dhcp server to use.")
78+
getCmd.PersistentFlags().StringVarP(&serverHostPortFlag, serverHostPortKey, "s", constants.DHCPDDHostPortDefault, constants.HostPortDocs)
7979

8080
if err := viper.BindPFlags(getCmd.PersistentFlags()); err != nil {
8181
log.Fatal(constants.CouldNotBindFlagsErrorMessage, rz.Err(err))

cmd/dhcpdd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func init() {
124124
hostPortFlag string
125125
)
126126

127-
rootCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, "Configuration file to use.")
127+
rootCmd.PersistentFlags().StringVarP(&configFileFlag, configFileKey, "f", configFileDefault, constants.ConfigurationFileDocs)
128128
rootCmd.PersistentFlags().StringVarP(&hostPortFlag, listenHostPortKey, "l", constants.DHCPDDHostPortDefault, "TCP listen host:port.")
129129

130130
if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {

0 commit comments

Comments
 (0)