check / check (push) Canceled after 0s
cmd/netwatch-server/main.go parsed the command line, ran the check-cidr and prepare-data-dir subcommands and built the fx application itself; the Go style guide puts all of that in internal/ or pkg/. The new package internal/cli does it, with the same arguments, messages and exit codes. main() is now os.Exit(cli.Main(os.Stderr, Appname, Version, os.Args[1:], cli.RunServer)): Main takes the writer for errors and the function that runs the server, so its tests give it a buffer and a function that fails them. Appname and Version stay in main, where the build sets Version. The function behind prepare-data-dir also takes the volume and the user's name, so its own tests give it a temporary directory and the user they run as. Model: opus-5-5
17 lines
527 B
Go
17 lines
527 B
Go
package cli
|
|
|
|
import "io"
|
|
|
|
// CheckCIDR exposes the check-cidr subcommand to the external tests,
|
|
// which read what it writes to stderr.
|
|
func CheckCIDR(stderr io.Writer, cidr string) int {
|
|
return checkCIDR(stderr, cidr)
|
|
}
|
|
|
|
// PrepareDataDir exposes the prepare-data-dir subcommand to the
|
|
// external tests, which give it a volume and a user of their own in
|
|
// place of /data and netwatch.
|
|
func PrepareDataDir(stderr io.Writer, volume, dataDir, username string) int {
|
|
return prepareDataDir(stderr, volume, dataDir, username)
|
|
}
|