GithubHelp home page GithubHelp logo

Comments (3)

davidism avatar davidism commented on June 2, 2024

pre-commit only allows adding args to the end

Yeah, but that doesn't prevent you from passing what you want:

command: my_command
additional_args: --opt a my_sub --other b

Besides that, it's already possible to introspect the available options and commands, so I'm not really clear what else would be needed or what it would do.

from click.

LecrisUT avatar LecrisUT commented on June 2, 2024

Let's dig into this a bit more. Consider the .pre-commit-hooks.yaml

- entry: my_command
  args: --opt a my_sub --other b

Now the user would want to add --root /path/to/root to my_command so they write in the .pre-commit-config.yaml

    - id: "..."
      args: [ --root, /path/to/root ]

This is than expanded and used as

$ my_command --opt a my_sub --other b --root /path/to/root

Note how --root is passed to my_sub instead of my_command. I don't remember the documentation page on how to make arguments pass from command to subcommand, but I remember trying that out and having had troubles with clashing kwargs that made adding --root as an option to my_sub and having it transparently passed down to my_command not possible. (Don't remember if it was even possible)

Now handling one argument is doable, but this CLI is growing rather quick and keeping synced all of the possible arguments that it supports can quickly be problematic. That's why it would be useful to write an automatic way of filtering the arguments so that we can re-order the arguments such that internally we have these equivalent:

$ precommit_my_command --opt a my_sub --other b --root /path/to/root
$ my_command --root /path/to/root --opt a my_sub --other b

from click.

LecrisUT avatar LecrisUT commented on June 2, 2024

Besides that, it's already possible to introspect the available options and commands, so I'm not really clear what else would be needed or what it would do.

I couldn't find the relevant API or documentation page.

Oh, if you are referring to inspect.signature, that simply gave me *args, **kwargs.

from click.

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.