package main

import (
	"fmt"
	"os"

	"github.com/bfirsh/whalebrew/cmd"
)

func main() {

	if len(os.Args) > 1 {
		// Check if not command exists
		if _, _, err := cmd.RootCmd.Find(os.Args); err != nil {
			// Check if file exists
			if _, err := os.Stat(os.Args[1]); err == nil {
				cmd.RootCmd.SetArgs(append([]string{"run"}, os.Args[1:]...))
			}
		}
	}

	if err := cmd.RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}

package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/bfirsh/whalebrew/cmd"
)

func main() {
	// HACK: if first argument starts with "/", prefix the subcommand run.
	// This allows us to use this command as a shebang, because we can't pass
	// the argument "run" in the shebang on Linux.
	if len(os.Args) > 1 && strings.HasPrefix(os.Args[1], "/") {
		cmd.RootCmd.SetArgs(append([]string{"run"}, os.Args[1:]...))
	}

	if err := cmd.RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}

Revert "Fix checking args (for working on windows)"
Revert "Fix checking args (for working on windows)"

This reverts commit 926f422e1dffdc35444e74bde2f52279a65cb3c3.
