Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed with example #4

Closed
lesovsky opened this issue Nov 16, 2021 · 1 comment
Closed

Failed with example #4

lesovsky opened this issue Nov 16, 2021 · 1 comment
Labels
question Further information is requested

Comments

@lesovsky
Copy link

Tried to make example with acmd, but have no success.

package main

import (
	"context"
	"fmt"
	"github.com/cristalhq/acmd"
	"os"
)

func main() {
	cmds := []acmd.Command{
		{
			Name:        "test",
			Description: "test cmd",
			Do: func(ctx context.Context, args []string) error {
				fmt.Println("test")
				return nil
			},
		},
	}

	r := acmd.RunnerOf(cmds, acmd.Config{
		AppName:        "test",
		AppDescription: "Test example",
		Version:        "v0.0.1",
		Output: os.Stdout,
		Args: os.Args,
	})

	if err := r.Run(); err != nil {
		panic(err)
	}

}

Build with go build main.go. All attempts to exec the command are failed with panic panic: acmd: cannot run command: no such command "./main".

@lesovsky
Copy link
Author

solved with using os.Args[1:].

@cristaloleg cristaloleg added the question Further information is requested label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants