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

Expose CLI model #106

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Expose CLI model #106

wants to merge 3 commits into from

Conversation

jawher
Copy link
Owner

@jawher jawher commented Jul 3, 2020

app.Model()

Fixes #104

@coveralls
Copy link

coveralls commented Jul 3, 2020

Coverage Status

Coverage decreased (-2.9%) to 92.68% when pulling 3da148f on issue-104-app-model into fbc50e9 on master.

@skyzyx
Copy link

skyzyx commented Jul 17, 2020

Getting a panic.

Pulled this branch:

GO111MODULE=on go get github.com/jawher/mow.cli@issue-104-app-model

Here's a pared-down file that shows the issue:

package main

import (
	"os"

	"github.com/davecgh/go-spew/spew"
	cli "github.com/jawher/mow.cli"
)

func main() {
	app := cli.App("myapp", "Description.")
	app.Version("version", "1")

	app.Command("do", "Do the thing.", func(config *cli.Cmd) {})

	spew.Dump(app.Model())

	err = app.Run(os.Args)
	if err != nil {
		exitErrorf(err)
	}
}

And the panic.

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/jawher/mow%2ecli.(*Cmd).Model(0xc00014e200, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/commands.go:157 +0xaec
github.com/jawher/mow%2ecli.(*Cmd).Model(0xc00014e100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/commands.go:167 +0x9fc
github.com/jawher/mow%2ecli.(*Cli).Model(...)
	/path/to/gocode/pkg/mod/github.com/jawher/mow.cli@v1.1.1-0.20200703143524-5e525d076aa4/cli.go:71
main.main()
	/path/to/gocode/src/github.com/skyzyx/project/src/main.go:16 +0x197

I don't see anything obvious in the code other than commands.go:157 references make() with a specific len as the second parameter. Maybe it's miscalculating?

@jawher
Copy link
Owner Author

jawher commented Jul 18, 2020

@skyzyx Nice catch ! I just pushed a commit to fix a bug in a slice allocation len 🤦‍♂️

@skyzyx
Copy link

skyzyx commented Nov 16, 2020

Had a chance to come back to this, and I'm quite happy with the results. THANK YOU!

@mmeloni
Copy link

mmeloni commented Oct 9, 2023

Ping

@skyzyx
Copy link

skyzyx commented Oct 9, 2023

This is available on the master branch, but has not been cut into a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose a model of the command structure
4 participants