GithubHelp home page GithubHelp logo

Supporting auto-completion about go-flags HOT 5 CLOSED

jessevdk avatar jessevdk commented on August 24, 2024
Supporting auto-completion

from go-flags.

Comments (5)

jessevdk avatar jessevdk commented on August 24, 2024

Yeah, it would be great to support something like this. For this to be really useful, there are still some things missing.

  1. A way to indicate that a flag argument is a file, could be a type Filename string alias
  2. A way to complete positional arguments in a certain way (for example as files).

from go-flags.

elazarl avatar elazarl commented on August 24, 2024
  1. In my way, a simple predefined Filename with FlagComplete function will do.
  2. What we could do (if we neglect issue #33 , which allows one to add completion in exactly the same way). Is to add FlagCompletePositional() method to the flag's struct itself.
type opt struct {
    verbose `short:"v"`
}
func (o *opt) FlagCompletePoistional(args []string) []string {
    if len(args) == 0 {
        return []string{"first1", "first2"}
    }
    return []string{"rest1", "rest2"}
}

from go-flags.

jessevdk avatar jessevdk commented on August 24, 2024

I would feel more inclined to then also fix #33. Additionally, the FlagComplete should accept a string and complete towards partial matches of that string, instead of just all matches. I would also only match flags (--verbose) if there is an initial -, which I think is more in line with how bash completion is normally implemented.

from go-flags.

jessevdk avatar jessevdk commented on August 24, 2024

I've finally gotten around to implementing this. Please see the docs for information on how it works and how you can enable bash-completion for your application.

from go-flags.

rlmcpherson avatar rlmcpherson commented on August 24, 2024

Awesome, thanks for this. Looking forward to using it.

from go-flags.

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.