blob: ed9ebfdec17ce01749c1bde417601b807cafeb1a (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package main
import (
"os"
"go.wit.com/lib/gui/prep"
)
/*
this parses the command line arguements
*/
var argv args
type args struct {
Trim bool `arg:"--trim" default:"true" help:"trim entries from go.sum"`
Verbose bool `arg:"--verbose" help:"show more"`
Restore bool `arg:"--restore" help:"only restore from go/pkg/mod/"`
Force bool `arg:"--force" help:"remove things and redo them no matter what"`
Purge *EmptyCmd `arg:"subcommand:purge" help:"purge all git notes. (this is where the autogenerated files are stored)"`
Smart *EmptyCmd `arg:"subcommand:lax" help:"try something but never do os.Exit(-1)"`
Strict *EmptyCmd `arg:"subcommand:strict" help:"never make go.* files unless everything is perfect"`
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
}
type EmptyCmd struct {
}
func (args) Version() string {
return "go-mod-clean " + VERSION + " Built on " + BUILDTIME
}
func (a args) Description() string {
return `
go-mod-clean will try to verify your go.* files are using the newest package versions
* Recreate go.* with 'go mod init' and 'go mod tidy'
* Set your required go in go.mod (default is go1.21
* Check that the most recent master branch versions are used
* Try to trim go.sum of non-existent entries
`
}
/*
handles shell autocomplete
*/
func (args) Appname() string {
return ARGNAME
}
func (args) Buildtime() (string, string) {
return BUILDTIME, VERSION
}
func (a args) DoAutoComplete(pb *prep.Auto) {
if pb.Cmd == "" {
pb.Autocomplete3([]string{"strict", "--restore", "purge", "lax", "--version"})
} else {
pb.SubCommand(pb.Argv...)
}
os.Exit(0)
}
|