diff --git a/internal/cli/build.go b/internal/cli/build.go index 8ec74f09..73f13f0d 100644 --- a/internal/cli/build.go +++ b/internal/cli/build.go @@ -43,7 +43,7 @@ func newBuildCmd( }, ArgsUsage: "Provide path to main package", Action: func(cliCtx *cli.Context) error { - mainPkg, err := getMainPkgFromArgs(cliCtx) + mainPkg, err := mainPkgPathFromArgs(cliCtx) if err != nil { return err } diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 4f60ced7..afc1bbc3 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -93,13 +93,17 @@ func newGetCmd(workdir string, bldr builder.Builder) *cli.Command { } } -func getMainPkgFromArgs(cCtx *cli.Context) (string, error) { - firstArg := cCtx.Args().First() - dirFromArg := strings.TrimSuffix(firstArg, "/main.neva") - if filepath.Ext(dirFromArg) != "" { +func mainPkgPathFromArgs(cCtx *cli.Context) (string, error) { + arg := cCtx.Args().First() + + path := strings.TrimSuffix(arg, "main.neva") + path = strings.TrimSuffix(path, "/") + + if filepath.Ext(path) != "" { return "", errors.New( "Use path to directory with executable package, relative to module root", ) } - return dirFromArg, nil + + return path, nil } diff --git a/internal/cli/run.go b/internal/cli/run.go index 0c5978af..f619cc43 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -24,7 +24,7 @@ func newRunCmd(workdir string, nativec compiler.Compiler) *cli.Command { }, ArgsUsage: "Provide path to main package", Action: func(cliCtx *cli.Context) error { - mainPkg, err := getMainPkgFromArgs(cliCtx) + mainPkg, err := mainPkgPathFromArgs(cliCtx) if err != nil { return err }