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

Allow to set the name of a pin #89

Open
NobbZ opened this issue Jun 19, 2024 · 8 comments
Open

Allow to set the name of a pin #89

NobbZ opened this issue Jun 19, 2024 · 8 comments

Comments

@NobbZ
Copy link

NobbZ commented Jun 19, 2024

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
Copy link
Owner

andir commented Jun 19, 2024

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
Copy link
Author

NobbZ commented Jun 19, 2024

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

Funny that --directory is displayed though.

@NobbZ
Copy link
Author

NobbZ commented Jun 20, 2024

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
Copy link
Owner

andir commented Jun 20, 2024

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
Copy link
Author

NobbZ commented Jun 20, 2024

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
Copy link
Owner

andir commented Jun 25, 2024

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
Copy link
Collaborator

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

@will
Copy link

will commented Sep 16, 2024

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

Thanks @NobbZ for posting how to actually do it! I couldn't figure it out at all :(

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

No branches or pull requests

4 participants