andir / npins

Nix dependency pinning. Very similar to Niv but has a few features that I personally wanted.
European Union Public License 1.2
164 stars 12 forks source link

Allow to set the name of a pin #89

Open NobbZ opened 1 month ago

NobbZ commented 1 month ago

sometimes I want to add repos with complicated names and have them simpler in the repo, sometimes I use prefix strings to filter and autogenerate drvs.

For those situations it would be nice if it was possible to provide a --name flag when adding.

Currently I work around that missing flag by manually editing the sources.json.

andir commented 1 month ago

You can already pass --name. You do npins add --name foobar github someone reponame

from the README:

$ npins help add
npins-add 0.2.4
Adds a new pin entry

USAGE:
    npins add [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -n, --dry-run    Don't actually apply the changes
    -h, --help       Prints help information

OPTIONS:
    -d, --directory <folder>    Base folder for sources.json and the boilerplate default.nix [env: NPINS_DIRECTORY=]
                                [default: npins]
        --name <name>           Custom name for the pin entry

SUBCOMMANDS:
    channel    Track a Nix channel
    git        Track a git repository
    github     Track a GitHub repository
    gitlab     Track a GitLab repository
    help       Prints this message or the help of the given subcommand(s)
    pypi       Track a package on PyPi
NobbZ commented 1 month ago

Oh, its not listed when doing npins add github --help, maybe the help could inherit parents switches?

Funny that --directory is displayed though.

NobbZ commented 1 month ago

It doesn't even work, unless use between add and github, this is a bit annoying. It should be position indipendant.

$ npins add github Feel-ix-343 markdown-oxide -b main --name nvim-oxide
error: Found argument '--name' which wasn't expected, or isn't valid in this context

USAGE:
    npins add github <owner> <repository> --branch <branch>

For more information try --help
$ npins add --name nvim-oxide github Feel-ix-343 markdown-oxide -b main
[INFO ] Adding 'nvim-oxide' …
    repository: https://github.com/Feel-ix-343/markdown-oxide.git
    branch: main
    revision: bd44db39f55b26a93aa56eb18eb105488a6a972d
    url: https://github.com/Feel-ix-343/markdown-oxide/archive/bd44db39f55b26a93aa56eb18eb105488a6a972d.tar.gz
    hash: 06h6s83g1rfvdxzgndi6krs787mvdal7am4pp1y07wz316bz7sdr
andir commented 1 month ago

I am not sure that is currently possible with the structopt library we are using. Probably a good change if you find documentation on that.

NobbZ commented 1 month ago

Have you considered using an actively developed library, like claps?

The structopt developers suggest it by themselves, as it offers same functionality:

https://docs.rs/structopt/latest/structopt/#maintenance

andir commented 1 month ago

Last time I tried to migrate the derive based API was missing some feature that we are using. I've not tried since. If you dare to try please go ahead. Happy to migrate but I can't dedicate that amount of time right now.

piegamesde commented 3 weeks ago

I don't think this is possible within the framework of clap, and structopt is just a proc macro frontend for that. You can mark flags as global, but there is no way to make them only propagate down in one direction