diff options
author | Franck Cuny <franck@fcuny.net> | 2024-05-06 19:28:58 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2024-05-06 19:29:57 -0700 |
commit | fdeb06f2c9e0bbb8e30de30c54e393cf19d3a3f8 (patch) | |
tree | f5972443b7adcdb6b030ff4391b001856a465d12 /cmd/flakeinfo/main.go | |
parent | move robloxenv to hashienv under `src' (diff) | |
download | world-fdeb06f2c9e0bbb8e30de30c54e393cf19d3a3f8.tar.gz |
messing with stuff
Diffstat (limited to 'cmd/flakeinfo/main.go')
-rw-r--r-- | cmd/flakeinfo/main.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/cmd/flakeinfo/main.go b/cmd/flakeinfo/main.go deleted file mode 100644 index 23a5169..0000000 --- a/cmd/flakeinfo/main.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "errors" - "flag" - "fmt" - "os" - "text/template" - - "github.com/fcuny/world/internal/version" - "github.com/fcuny/world/pkg/flake/lock" -) - -const usage = `Usage: - flake-info [flake.lock] - -Options: - -v, --version Print version information - -h, --help Print this message -` - -const tmplInput = ` • repository: {{ .Locked.Repository }} - • updated on: {{ .Locked.LastModifiedRFC3339 }} - -` - -func main() { - flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) } - - var ( - flakeLockPath string - versionFlag bool - ) - - flag.StringVar(&flakeLockPath, "flake-lock", "flake.lock", "path to the flake lock file") - flag.BoolVar(&versionFlag, "version", false, "Print version information") - flag.BoolVar(&versionFlag, "v", false, "Print version information") - - flag.Parse() - - if versionFlag { - information := version.VersionAndBuildInfo() - fmt.Println(information) - return - } - - if _, err := os.Stat(flakeLockPath); err != nil { - if errors.Is(err, os.ErrNotExist) { - fmt.Fprintf(os.Stderr, "%s does not exists\n", flakeLockPath) - } else { - fmt.Fprintf(os.Stderr, "failed to check if %s exists: %v\n", flakeLockPath, err) - } - os.Exit(1) - } - - lock, err := lock.New(flakeLockPath) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to parse the lockfile for %s: %+v\n", flakeLockPath, err) - os.Exit(1) - } - - for nodeName, node := range lock.Nodes { - tmpl, err := template.New("tmpl").Parse(tmplInput) - if err != nil { - panic(err) - } - fmt.Printf("%s\n", nodeName) - err = tmpl.Execute(os.Stdout, node) - if err != nil { - panic(err) - } - } -} |