1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// SPDX-FileCopyrightText: 2020 Ethel Morgan
//
// SPDX-License-Identifier: MIT
package flag
import (
"fmt"
"os"
"time"
)
var (
CommandLine = NewFlagSet(os.Args[0], ExitOnError)
Usage = func() {
fmt.Fprintf(CommandLine.Output(), "Usage of %s:\n", os.Args[0])
CommandLine.PrintDefaults()
}
)
func init() {
CommandLine.Usage = runUsageVariable
}
func runUsageVariable() {
Usage()
}
func Parse() {
_ = CommandLine.Parse(os.Args[1:])
}
func String(flagName, defaultValue, description string) *string {
return CommandLine.String(flagName, defaultValue, description)
}
func Int(flagName string, defaultValue int, description string) *int {
return CommandLine.Int(flagName, defaultValue, description)
}
func Duration(flagName string, defaultValue time.Duration, description string) *time.Duration {
return CommandLine.Duration(flagName, defaultValue, description)
}
func Custom(flagName, defaultValue, description string, parser ParseFunc) *interface{} {
return CommandLine.Custom(flagName, defaultValue, description, parser)
}
func Bool(flagName string, defaultValue bool, description string) *bool {
return CommandLine.Bool(flagName, defaultValue, description)
}
|