Coder Social home page Coder Social logo

Comments (5)

dearchap avatar dearchap commented on June 13, 2024

@bobheadxi Can you provide an example of what you are doing in the completion func ?

from cli.

bobheadxi avatar bobheadxi commented on June 13, 2024

Can you provide an example of what you are doing in the completion func ?

The bug occurs even if you don't do anything in the completion func directly (see description - it seems to happen in urfave/cli before the handler actually executes), but sourcegraph/sourcegraph#58569 has a concrete example

from cli.

dearchap avatar dearchap commented on June 13, 2024

The reason I ask is that I dont see the issue when the completion func is not set. Let me investigate further. I have specified an invalid flag on the command line and then tried completion of a valid flag and it works just fine

$ issue_1822 command subcommand --stss --
--help        --stringflag  
$ issue_1822 command subcommand --stss --stringflag

from cli.

bobheadxi avatar bobheadxi commented on June 13, 2024

Hm, now that I'm taking a closer look it seems I can't reproduce it either:

	if err := (&cli.App{
		Name:                 "sg",
		EnableBashCompletion: true,
		Commands: []*cli.Command{{
			Name: "bar",
			Flags: []cli.Flag{
				&cli.StringFlag{
					Name:  "stringflag",
					Value: "vcs",
				},
			},
// internal helper used in my panic scenario
			BashComplete: completions.CompletePositionalArgs(func(args cli.Args) (options []string) {
				return []string{args.First()}
			}),
			Action: func(ctx *cli.Context) error {
				println("action!")
				return nil
			},
		}},
	}).RunContext(context.Background(), os.Args); err != nil {
		println(err.Error())
		os.Exit(1)
	}

However, in our full CLI app, the panic continues to point to the same place in the issue description, i.e.

cli/help.go

Line 467 in c023d9b

if args := cCtx.Args(); args.Present() {
, and the stacktrace looks like the one I shared previously. We do some pretty extensive setup so there might be an issue deep in there (though we skip most setup if we detect the bash completion flag), but the stacktrace doesn't seem to indicate that - let me dig into this some more

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.