From 00fca4f9b7c5bfd057a5717f869c0d8bc5a8d58f Mon Sep 17 00:00:00 2001 From: Jaxon teBoekhorst Date: Mon, 23 Dec 2024 16:51:17 -0500 Subject: [PATCH 1/6] Updated urfave/cli to version 3 Updated urfave/cli to allow for reorded cli commands eg: zvm i master --zls Before only zvm i --zls master was possible due to the way that v2 parses flags --- go.mod | 2 +- go.sum | 2 ++ main.go | 91 +++++++++++++++++++++++++++++---------------------------- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/go.mod b/go.mod index 74169cb..fc01f90 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/urfave/cli/v2 v2.27.2 + github.com/urfave/cli/v3 v3.0.0-beta1 golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect golang.org/x/term v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 7b77017..9b62323 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,8 @@ github.com/tristanisham/clr v0.0.0-20221004001624-00ee60046d85 h1:zD4b2hs7jZ2sJt github.com/tristanisham/clr v0.0.0-20221004001624-00ee60046d85/go.mod h1:cKn2HV8Beq81OHjb2gja2ZiU4HAEQ6LSuxyaIT5Mg7o= github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= +github.com/urfave/cli/v3 v3.0.0-beta1 h1:6DTaaUarcM0wX7qj5Hcvs+5Dm3dyUTBbEwIWAjcw9Zg= +github.com/urfave/cli/v3 v3.0.0-beta1/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= diff --git a/main.go b/main.go index 419c566..268b82d 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ package main import ( + "context" "errors" "fmt" "os" @@ -12,7 +13,7 @@ import ( "github.com/tristanisham/zvm/cli" "github.com/tristanisham/zvm/cli/meta" - opts "github.com/urfave/cli/v2" + opts "github.com/urfave/cli/v3" "github.com/charmbracelet/log" ) @@ -22,17 +23,17 @@ var ( printUpgradeNotice bool = true ) -var zvmApp = &opts.App{ +var zvmApp = &opts.Command{ Name: "ZVM", Usage: "Zig Version Manager", Description: "zvm lets you easily install, upgrade, and switch between different versions of Zig.", - HelpName: "zvm", - Version: meta.VerCopy, - Copyright: "Copyright © 2022 Tristan Isham", - Suggest: true, - Before: func(ctx *opts.Context) error { + // HelpName: "zvm", + Version: meta.VerCopy, + Copyright: "Copyright © 2022 Tristan Isham", + Suggest: true, + Before: func(ctx context.Context, cmd *opts.Command) (context.Context, error) { zvm = *cli.Initialize() - return nil + return nil, nil }, // app-global flags Flags: []opts.Flag{ @@ -40,7 +41,7 @@ var zvmApp = &opts.App{ Name: "color", Usage: "enable (on, yes/y, enabled, true) or disable (off, no/n, disabled, false) colored ZVM output", Value: "toggle", - Action: func(ctx *opts.Context, val string) error { + Action: func(ctx context.Context, cmd *opts.Command, val string) error { switch val { case "on", "yes", "enabled", "y", "true": zvm.Settings.YesColor() @@ -78,10 +79,10 @@ var zvmApp = &opts.App{ }, }, Description: "To install the latest version, use `master`", - Args: true, - ArgsUsage: " ", - Action: func(ctx *opts.Context) error { - versionArg := strings.TrimPrefix(ctx.Args().First(), "v") + // Args: true, + ArgsUsage: " ", + Action: func(ctx context.Context, cmd *opts.Command) error { + versionArg := strings.TrimPrefix(cmd.Args().First(), "v") if versionArg == "" { return errors.New("no version provided") @@ -92,12 +93,12 @@ var zvmApp = &opts.App{ force := zvm.Settings.AlwaysForceInstall - if ctx.Bool("force") { - force = ctx.Bool("force") + if cmd.Bool("force") { + force = cmd.Bool("force") } zlsCompat := "only-runtime" - if ctx.Bool("full") { + if cmd.Bool("full") { zlsCompat = "full" } @@ -108,7 +109,7 @@ var zvmApp = &opts.App{ } // Install ZLS (if requested) - if ctx.Bool("zls") { + if cmd.Bool("zls") { if err := zvm.InstallZls(req.Package, zlsCompat, force); err != nil { return err } @@ -120,18 +121,18 @@ var zvmApp = &opts.App{ { Name: "use", Usage: "switch between versions of Zig", - Args: true, + // Args: true, Flags: []opts.Flag{ &opts.BoolFlag{ Name: "sync", Usage: "sync your current version of Zig with the repository", }, }, - Action: func(ctx *opts.Context) error { - if ctx.Bool("sync") { + Action: func(ctx context.Context, cmd *opts.Command) error { + if cmd.Bool("sync") { return zvm.Sync() } else { - versionArg := strings.TrimPrefix(ctx.Args().First(), "v") + versionArg := strings.TrimPrefix(cmd.Args().First(), "v") return zvm.Use(versionArg) } }, @@ -139,10 +140,10 @@ var zvmApp = &opts.App{ { Name: "run", Usage: "run a command with the given Zig version", - Args: true, - Action: func(ctx *opts.Context) error { - versionArg := strings.TrimPrefix(ctx.Args().First(), "v") - cmds := ctx.Args().Tail() + // Args: true, + Action: func(ctx context.Context, cmd *opts.Command) error { + versionArg := strings.TrimPrefix(cmd.Args().First(), "v") + cmds := cmd.Args().Tail() return zvm.Run(versionArg, cmds) }, @@ -151,7 +152,7 @@ var zvmApp = &opts.App{ Name: "list", Usage: "list installed Zig versions. Flag `--all` to see remote options", Aliases: []string{"ls"}, - Args: true, + // Args: true, Flags: []opts.Flag{ &opts.BoolFlag{ Name: "all", @@ -163,11 +164,11 @@ var zvmApp = &opts.App{ Usage: "list set version maps", }, }, - Action: func(ctx *opts.Context) error { + Action: func(ctx context.Context, cmd *opts.Command) error { log.Debug("Version Map", "url", zvm.Settings.VersionMapUrl, "cmd", "list/ls") - if ctx.Bool("all") { + if cmd.Bool("all") { return zvm.ListRemoteAvailable() - } else if ctx.Bool("vmu") { + } else if cmd.Bool("vmu") { if len(zvm.Settings.VersionMapUrl) == 0 { if err := zvm.Settings.ResetVersionMap(); err != nil { return err @@ -194,23 +195,23 @@ var zvmApp = &opts.App{ Name: "uninstall", Usage: "remove an installed version of Zig", Aliases: []string{"rm"}, - Args: true, - Action: func(ctx *opts.Context) error { - versionArg := strings.TrimPrefix(ctx.Args().First(), "v") + // Args: true, + Action: func(ctx context.Context, cmd *opts.Command) error { + versionArg := strings.TrimPrefix(cmd.Args().First(), "v") return zvm.Uninstall(versionArg) }, }, { Name: "clean", Usage: "remove build artifacts (good if you're a scrub)", - Action: func(ctx *opts.Context) error { + Action: func(ctx context.Context, cmd *opts.Command) error { return zvm.Clean() }, }, { Name: "upgrade", Usage: "self-upgrade ZVM", - Action: func(ctx *opts.Context) error { + Action: func(ctx context.Context, cmd *opts.Command) error { printUpgradeNotice = false return zvm.Upgrade() }, @@ -218,16 +219,16 @@ var zvmApp = &opts.App{ { Name: "vmu", Usage: "set ZVM's version map URL for custom Zig distribution servers", - Args: true, - Subcommands: []*opts.Command{ + // Args: true, + Commands: []*opts.Command{ { - Name: "zig", - Usage: "set ZVM's version map URL for custom Zig distribution servers", - Args: true, + Name: "zig", + Usage: "set ZVM's version map URL for custom Zig distribution servers", + // Args: true, ArgsUsage: "", - Action: func(ctx *opts.Context) error { - url := ctx.Args().First() + Action: func(ctx context.Context, cmd *opts.Command) error { + url := cmd.Args().First() log.Debug("user passed VMU", "url", url) switch url { @@ -253,9 +254,9 @@ var zvmApp = &opts.App{ { Name: "zls", Usage: "set ZVM's version map URL for custom ZLS Release Workers", - Args: true, - Action: func(ctx *opts.Context) error { - url := ctx.Args().First() + // Args: true, + Action: func(ctx context.Context, cmd *opts.Command) error { + url := cmd.Args().First() log.Debug("user passed zrw", "url", url) switch url { @@ -301,7 +302,7 @@ func main() { } // run and report errors - if err := zvmApp.Run(os.Args); err != nil { + if err := zvmApp.Run(context.Background(), os.Args); err != nil { // if meta.VERSION == "v0.7.9" && errors.Is(err, cli.ErrInvalidVersionMap) { // meta.CtaGeneric("Help", `Encountered an issue while trying to install ZLS for Zig 'master'. From 062522afab554e22f5a42645bd58493d9f89753d Mon Sep 17 00:00:00 2001 From: Tristan Isham Date: Wed, 22 Jan 2025 15:10:56 -0500 Subject: [PATCH 2/6] updated pr --- LICENSE | 2 +- build.ts | 2 +- cli/clean.go | 2 +- cli/config.go | 2 +- cli/error.go | 2 +- cli/fileperms_unix.go | 2 +- cli/fileperms_win.go | 2 +- cli/install.go | 2 +- cli/install_test.go | 2 +- cli/ls.go | 2 +- cli/meta/cta.go | 2 +- cli/meta/errors.go | 2 +- cli/meta/symlink_unix.go | 2 +- cli/meta/symlink_win.go | 2 +- cli/meta/version.go | 4 ++-- cli/run.go | 8 ++++---- cli/settings.go | 2 +- cli/sync.go | 2 +- cli/uninstall.go | 2 +- cli/upgrade.go | 2 +- cli/use.go | 2 +- cli/version.go | 2 +- go.mod | 19 +++++++++++-------- go.sum | 17 +++++++++++++++++ main.go | 4 ++-- 25 files changed, 56 insertions(+), 36 deletions(-) diff --git a/LICENSE b/LICENSE index 0889134..a092761 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ The MIT License (MIT) -Copyright © 2022 Tristan Isham +Copyright © 2025 Tristan Isham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/build.ts b/build.ts index 2bb74b6..c16ebb1 100644 --- a/build.ts +++ b/build.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/clean.go b/cli/clean.go index 76ec25b..dfbc27c 100644 --- a/cli/clean.go +++ b/cli/clean.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package cli diff --git a/cli/config.go b/cli/config.go index 41fd030..b7fd34d 100644 --- a/cli/config.go +++ b/cli/config.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/error.go b/cli/error.go index 67ada75..4758836 100644 --- a/cli/error.go +++ b/cli/error.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/fileperms_unix.go b/cli/fileperms_unix.go index 274294b..c7c27c9 100644 --- a/cli/fileperms_unix.go +++ b/cli/fileperms_unix.go @@ -1,6 +1,6 @@ //go:build linux -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/fileperms_win.go b/cli/fileperms_win.go index d607761..2c30316 100644 --- a/cli/fileperms_win.go +++ b/cli/fileperms_win.go @@ -1,6 +1,6 @@ //go:build !linux -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/install.go b/cli/install.go index e984acc..c95f218 100644 --- a/cli/install.go +++ b/cli/install.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/install_test.go b/cli/install_test.go index 40e9e2c..ddb89c0 100644 --- a/cli/install_test.go +++ b/cli/install_test.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/ls.go b/cli/ls.go index 1eadea1..171eacc 100644 --- a/cli/ls.go +++ b/cli/ls.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/meta/cta.go b/cli/meta/cta.go index 309e5a7..efc8985 100644 --- a/cli/meta/cta.go +++ b/cli/meta/cta.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package meta diff --git a/cli/meta/errors.go b/cli/meta/errors.go index ddc894d..7eea213 100644 --- a/cli/meta/errors.go +++ b/cli/meta/errors.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package meta diff --git a/cli/meta/symlink_unix.go b/cli/meta/symlink_unix.go index 0b54ef8..1a12781 100644 --- a/cli/meta/symlink_unix.go +++ b/cli/meta/symlink_unix.go @@ -1,6 +1,6 @@ //go:build !windows -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package meta diff --git a/cli/meta/symlink_win.go b/cli/meta/symlink_win.go index 3c6569f..0db3f79 100644 --- a/cli/meta/symlink_win.go +++ b/cli/meta/symlink_win.go @@ -1,6 +1,6 @@ //go:build windows -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package meta diff --git a/cli/meta/version.go b/cli/meta/version.go index c12bb6e..cee478d 100644 --- a/cli/meta/version.go +++ b/cli/meta/version.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package meta @@ -9,7 +9,7 @@ import ( ) const ( - VERSION = "v0.8.2" + VERSION = "v0.8.5" // VERSION = "v0.0.0" // For testing zvm upgrade ) diff --git a/cli/run.go b/cli/run.go index 801be76..e2ae972 100644 --- a/cli/run.go +++ b/cli/run.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package cli @@ -26,7 +26,7 @@ func (z *ZVM) Run(version string, cmd []string) error { // if err != nil { // return fmt.Errorf("%w: no Zig version found; %w", ErrMissingBundlePath, err) // } - + // return z.runZig("bin", cmd) } @@ -71,12 +71,12 @@ func (z *ZVM) runZig(version string, cmd []string) error { if runtime.GOOS == "windows" { zigExe = "zig.exe" } - + bin := strings.TrimSpace(filepath.Join(z.baseDir, version, zigExe)) log.Debug("runZig", "bin", bin) if stat, err := os.Lstat(bin); err != nil { - + name := version if stat != nil { name = stat.Name() diff --git a/cli/settings.go b/cli/settings.go index 3bd7aa6..ca0baba 100644 --- a/cli/settings.go +++ b/cli/settings.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/sync.go b/cli/sync.go index 30deb65..9f2584e 100644 --- a/cli/sync.go +++ b/cli/sync.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/uninstall.go b/cli/uninstall.go index d5074ad..801918b 100644 --- a/cli/uninstall.go +++ b/cli/uninstall.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/upgrade.go b/cli/upgrade.go index ed25eb3..eb2e285 100644 --- a/cli/upgrade.go +++ b/cli/upgrade.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/use.go b/cli/use.go index bced1f8..8af46e4 100644 --- a/cli/use.go +++ b/cli/use.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/cli/version.go b/cli/version.go index 6bba3bb..59cc68d 100644 --- a/cli/version.go +++ b/cli/version.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. diff --git a/go.mod b/go.mod index fc01f90..c4146b0 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,20 @@ module github.com/tristanisham/zvm -go 1.22 +go 1.22.0 + +toolchain go1.23.4 require ( - github.com/charmbracelet/lipgloss v0.10.0 + github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 - github.com/schollz/progressbar/v3 v3.14.2 + github.com/schollz/progressbar/v3 v3.18.0 github.com/tristanisham/clr v0.0.0-20221004001624-00ee60046d85 - golang.org/x/mod v0.16.0 - golang.org/x/sys v0.18.0 + golang.org/x/mod v0.22.0 + golang.org/x/sys v0.29.0 ) require ( + github.com/charmbracelet/x/ansi v0.7.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect @@ -22,12 +25,12 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/urfave/cli/v3 v3.0.0-beta1 - golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + golang.org/x/term v0.28.0 // indirect ) diff --git a/go.sum b/go.sum index 9b62323..acb7fad 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,12 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= +github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= +github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= +github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404= +github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -19,6 +23,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= @@ -35,12 +41,15 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/progressbar/v3 v3.14.2 h1:EducH6uNLIWsr560zSV1KrTeUb/wZGAHqyMFIEa99ks= github.com/schollz/progressbar/v3 v3.14.2/go.mod h1:aQAZQnhF4JGFtRJiw/eobaXpsqpVQAftEQ+hLGXaRc4= +github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQmCN62HpA= +github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tristanisham/clr v0.0.0-20221004001624-00ee60046d85 h1:zD4b2hs7jZ2sJtgtNdpMZyo4D4/Ifct8SMxvPNNkHzs= github.com/tristanisham/clr v0.0.0-20221004001624-00ee60046d85/go.mod h1:cKn2HV8Beq81OHjb2gja2ZiU4HAEQ6LSuxyaIT5Mg7o= +github.com/tristanisham/clr v0.0.0-20251004001624-00ee60046d85/go.mod h1:cKn2HV8Beq81OHjb2gja2ZiU4HAEQ6LSuxyaIT5Mg7o= github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/urfave/cli/v3 v3.0.0-beta1 h1:6DTaaUarcM0wX7qj5Hcvs+5Dm3dyUTBbEwIWAjcw9Zg= @@ -49,14 +58,22 @@ github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 268b82d..3dc8a00 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Copyright 2022 Tristan Isham. All rights reserved. +// Copyright 2025 Tristan Isham. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. @@ -29,7 +29,7 @@ var zvmApp = &opts.Command{ Description: "zvm lets you easily install, upgrade, and switch between different versions of Zig.", // HelpName: "zvm", Version: meta.VerCopy, - Copyright: "Copyright © 2022 Tristan Isham", + Copyright: "Copyright © 2025 Tristan Isham", Suggest: true, Before: func(ctx context.Context, cmd *opts.Command) (context.Context, error) { zvm = *cli.Initialize() From 2f5c98511595512e955ef6904d4640e599136b0d Mon Sep 17 00:00:00 2001 From: Tristan Isham Date: Wed, 22 Jan 2025 15:12:29 -0500 Subject: [PATCH 3/6] updated toolchain --- go.mod | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c4146b0..7b984ad 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/tristanisham/zvm -go 1.22.0 - -toolchain go1.23.4 +go 1.23.4 require ( github.com/charmbracelet/lipgloss v1.0.0 From 0ef6af694e344b2d920d97c7ed2797ea90355640 Mon Sep 17 00:00:00 2001 From: Tristan Isham Date: Wed, 22 Jan 2025 15:14:06 -0500 Subject: [PATCH 4/6] added new name --- main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.go b/main.go index 3dc8a00..44a8413 100644 --- a/main.go +++ b/main.go @@ -24,10 +24,9 @@ var ( ) var zvmApp = &opts.Command{ - Name: "ZVM", + Name: "zvm", Usage: "Zig Version Manager", Description: "zvm lets you easily install, upgrade, and switch between different versions of Zig.", - // HelpName: "zvm", Version: meta.VerCopy, Copyright: "Copyright © 2025 Tristan Isham", Suggest: true, From 7c488719972cd51d98cbc0652660e814fc97e131 Mon Sep 17 00:00:00 2001 From: Tristan Isham Date: Wed, 22 Jan 2025 15:21:30 -0500 Subject: [PATCH 5/6] added use notice --- cli/use.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/use.go b/cli/use.go index 8af46e4..f235611 100644 --- a/cli/use.go +++ b/cli/use.go @@ -31,7 +31,12 @@ func (z *ZVM) Use(ver string) error { } } - return z.setBin(ver) + if err := z.setBin(ver); err != nil { + return err + } + + fmt.Printf("Now using Zig %s\n", ver) + return nil } func (z *ZVM) setBin(ver string) error { @@ -66,6 +71,7 @@ func (z *ZVM) setBin(ver string) error { return err } + log.Debug("Use", "version", ver) return nil } From d6257268ccf10fd29c788adcf44124dbbe8bd808 Mon Sep 17 00:00:00 2001 From: Tristan Isham Date: Wed, 22 Jan 2025 15:26:34 -0500 Subject: [PATCH 6/6] moved cli to main file --- cli/use.go | 7 +------ main.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/use.go b/cli/use.go index f235611..6111daa 100644 --- a/cli/use.go +++ b/cli/use.go @@ -31,12 +31,7 @@ func (z *ZVM) Use(ver string) error { } } - if err := z.setBin(ver); err != nil { - return err - } - - fmt.Printf("Now using Zig %s\n", ver) - return nil + return z.setBin(ver) } func (z *ZVM) setBin(ver string) error { diff --git a/main.go b/main.go index 44a8413..749b7ed 100644 --- a/main.go +++ b/main.go @@ -27,9 +27,9 @@ var zvmApp = &opts.Command{ Name: "zvm", Usage: "Zig Version Manager", Description: "zvm lets you easily install, upgrade, and switch between different versions of Zig.", - Version: meta.VerCopy, - Copyright: "Copyright © 2025 Tristan Isham", - Suggest: true, + Version: meta.VerCopy, + Copyright: "Copyright © 2025 Tristan Isham", + Suggest: true, Before: func(ctx context.Context, cmd *opts.Command) (context.Context, error) { zvm = *cli.Initialize() return nil, nil @@ -132,7 +132,12 @@ var zvmApp = &opts.Command{ return zvm.Sync() } else { versionArg := strings.TrimPrefix(cmd.Args().First(), "v") - return zvm.Use(versionArg) + if err := zvm.Use(versionArg); err != nil { + return err + } + + fmt.Printf("Now using Zig %s\n", versionArg) + return nil } }, },