Skip to content

Commit

Permalink
removed default runner until I figure out how to not parse remaining …
Browse files Browse the repository at this point in the history
…flags using our CLI parser.
  • Loading branch information
tristanisham committed Nov 14, 2024
1 parent 4cc6fb7 commit c14087e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func validVmuAlis(version string) bool {

func (z ZVM) zigPath() (string, error) {
zig := filepath.Join(z.baseDir, "bin", "zig")

log.Debug("zigPath", "zig", zig)
if _, err := os.Stat(zig); err != nil {
return "", err
}
Expand Down
30 changes: 20 additions & 10 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ import (
"path/filepath"
"slices"
"strings"

"github.com/charmbracelet/log"
)

// Run the given Zig compiler with the provided arguments
func (z *ZVM) Run(version string, cmd []string) error {

log.Debug("Run", "version", version, "cmds", strings.Join(cmd, ", "))
if len(version) == 0 {
zig, err := z.zigPath()
if err != nil {
return fmt.Errorf("%w: no Zig version found", ErrMissingBundlePath)
}

return z.runZig(zig, cmd)
return fmt.Errorf("no zig version provided. If you want to run your set version of Zig, please use 'zig'")
// zig, err := z.zigPath()
// log.Debug("Run", "zig path", zig)
// if err != nil {
// return fmt.Errorf("%w: no Zig version found; %w", ErrMissingBundlePath, err)
// }

// return z.runZig("bin", cmd)
}

installedVersions, err := z.GetInstalledVersions()
Expand All @@ -47,7 +51,7 @@ func (z *ZVM) Run(version string, cmd []string) error {
}
}

fmt.Printf("It looks like %s isn't installed. Would you like to install it first? [y/n]\n", version)
fmt.Printf("It looks like %s isn't installed. Would you like to install it? [y/n]\n", version)

if getConfirmation() {
if err = z.Install(version, false); err != nil {
Expand All @@ -64,8 +68,14 @@ func (z *ZVM) Run(version string, cmd []string) error {
func (z *ZVM) runZig(version string, cmd []string) error {
bin := strings.TrimSpace(filepath.Join(z.baseDir, version, "zig"))

if stat, err := os.Stat(bin); err != nil {
return fmt.Errorf("%w: %s", err, stat.Name())
log.Debug("runZig", "bin", bin)
if stat, err := os.Lstat(bin); err != nil {

name := version
if stat != nil {
name = stat.Name()
}
return fmt.Errorf("%w: %s", err, name)
}

// the logging here really muddies up the output of the Zig compiler
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ var zvmApp = &opts.App{
Args: true,
Action: func(ctx *opts.Context) error {
versionArg := strings.TrimPrefix(ctx.Args().First(), "v")
cmd := ctx.Args().Tail()
return zvm.Run(versionArg, cmd)
cmds := ctx.Args().Tail()
return zvm.Run(versionArg, cmds)

},
},
{
Expand Down

0 comments on commit c14087e

Please sign in to comment.