forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subprograms.go
47 lines (37 loc) · 857 Bytes
/
subprograms.go
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
47
package program
import (
"fmt"
"os"
"github.com/u-root/u-root/cmds/core/elvish/build"
)
// ShowHelp shows help message.
type ShowHelp struct {
flag *flagSet
}
func (s ShowHelp) Main([]string) int {
usage(os.Stdout, s.flag)
return 0
}
type ShowCorrectUsage struct {
message string
flag *flagSet
}
func (s ShowCorrectUsage) Main([]string) int {
usage(os.Stderr, s.flag)
return 2
}
// ShowVersion shows the version.
type ShowVersion struct{}
func (ShowVersion) Main([]string) int {
fmt.Println(build.Version)
fmt.Fprintln(os.Stderr, "-version is deprecated and will be removed in 0.12. Use -buildinfo instead.")
return 0
}
// ShowBuildInfo shows build information.
type ShowBuildInfo struct {
}
func (info ShowBuildInfo) Main([]string) int {
fmt.Println("version:", build.Version)
fmt.Println("builder:", build.Builder)
return 0
}