Skip to content

Commit 3a91f46

Browse files
committed
update readme to mention -h/--help usage message changes
also gofmt
1 parent 3386faf commit 3a91f46

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Use this package to:
88
- Define different environment variables, their default value, and description.
99
- Define different environments, e.g. one set of environment variables for each
1010
subcommand.
11+
- Get a description of the environment variables defined using the `-h/--help`
12+
command line flag parsing behavior.
1113
- Get a description of the environment variables defined by setting `HELP` or
1214
`H`.
1315
- Add support for your types to be used as environment variables.

env.go

+16-15
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ func (e *EnvSet) PrintDefaults() {
508508
// For an integer valued variable x, the default output has the form
509509
//
510510
// x int
511-
// description-message-for-x (default: 7)
511+
//
512+
// description-message-for-x (default: 7)
512513
//
513514
// The description message will appear on a separate line.
514515
// The parenthetical default is omitted if the default is the zero value for
@@ -522,7 +523,8 @@ func (e *EnvSet) PrintDefaults() {
522523
// the output will be
523524
//
524525
// I directory
525-
// search directory for include files.
526+
//
527+
// search directory for include files.
526528
//
527529
// To change the destination for variable messages, call [Environment].SetOutput.
528530
func PrintDefaults() {
@@ -666,7 +668,6 @@ func (e *EnvSet) Uint64(name string, value uint64, description string) *uint64 {
666668
return p
667669
}
668670

669-
670671
// Uint64 defines a uint64 environment variable with specified name, default value, and description string.
671672
// The return value is the address of a uint64 variable that stores the value of the variable.
672673
func Uint64(name string, value uint64, description string) *uint64 {
@@ -959,20 +960,20 @@ func (e *EnvSet) Init(name string, errorHandling ErrorHandling) {
959960
// Error messages when parsing command line flags will also print out
960961
// the description of the environment variables expected.
961962
func Link(f *flag.FlagSet, e *EnvSet) {
962-
flagSetUsage := f.Usage
963-
if flagSetUsage == nil {
964-
flagSetUsage = f.PrintDefaults
965-
}
966-
f.Usage = func() {
967-
flagSetUsage()
968-
e.usage()
969-
}
963+
flagSetUsage := f.Usage
964+
if flagSetUsage == nil {
965+
flagSetUsage = f.PrintDefaults
966+
}
967+
f.Usage = func() {
968+
flagSetUsage()
969+
e.usage()
970+
}
970971
}
971972

972973
func init() {
973-
// Take over the default error reporting behavior of the flag package.
974-
// By default the flag package will call the flag.CommandLine.Usage
975-
// function when an error is encountered while parsing command line flags.
974+
// Take over the default error reporting behavior of the flag package.
975+
// By default the flag package will call the flag.CommandLine.Usage
976+
// function when an error is encountered while parsing command line flags.
976977

977-
Link(flag.CommandLine, Environment)
978+
Link(flag.CommandLine, Environment)
978979
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/edoput/env
22

3-
go 1.22.0
3+
go 1.23

0 commit comments

Comments
 (0)