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

Suggested feature: Add a "get url" command #84

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rybern
Copy link

@rybern rybern commented Nov 16, 2023

Implements #83

This PR adds a new command, fh get-url, that just prints the URL to stdout. For example:

>> fh help
fh: a CLI for interacting with FlakeHub

Usage: fh [OPTIONS] <COMMAND>

Commands:
  add         Adds a flake input to your flake.nix
  get-url     Prints the URL of a given FlakeHub flake
  completion  Prints completion for shells to use
  init        Create a new flake.nix using an opinionated interactive initializer
  list        Lists key FlakeHub resources
  search      Searches FlakeHub for flakes that match your query
  convert     Convert flake inputs to FlakeHub when possible
  login       Login to FlakeHub in order to allow authenticated fetching of flakes
  status      Check your FlakeHub token status
  eject       Convert flake inputs from FlakeHub back to GitHub
  help        Print this message or the help of the given subcommand(s)
...

>> fh help get-url
Prints the URL of a given FlakeHub flake

Usage: fh get-url [OPTIONS] <INPUT_REF>

Arguments:
  <INPUT_REF>
          The FlakeHub reference to print as a URL
          
          A FlakeHub reference is of a form like `NixOS/nixpkgs` or `NixOS/nixpkgs/0.2305.*`
...

>> fh get-url mrcjkb/haskell-tools.nvim
https://flakehub.com/f/mrcjkb/haskell-tools.nvim/3.0.0.tar.gz

>> nix flake show `fh get-url mrcjkb/haskell-tools.nvim`
https://api.flakehub.com/f/pinned/mrcjkb/haskell-tools.nvim/3.0.0/018b782d-beff-7769-b535-70b13b566cea/source.tar.gz?narHash=sha256-OWxcxnn7XrezQlJoO43P4z68KcFB%2fJqk4NpUBjoF12E=
├───checks
│   ├───aarch64-darwin
│   │   ├───haskell-tools-test: derivation 'haskell-tools-haskell-tools.nvim-scm-1'
│   │   ├───haskell-tools-test-nightly: derivation 'haskell-tools-nightly-haskell-tools.nvim-scm-1'
│   │   ├───haskell-tools-test-no-hls: derivation 'haskell-tools-no-hls-haskell-tools.nvim-scm-1'
...

I know I just posted the issue, just thought it'd be fun to write Rust for a minute 😄

As a side note - the development experience jumping into this project was AMAZING! I'm not even familiar with Rust tooling, but I cloned the repo and direnv took care of everything for me. So cool.

@lucperkins
Copy link
Member

lucperkins commented Dec 5, 2023

@rybern We talked a bit internally about this and we think that this would be a cool capability to have 😄 We agree that having a dedicated command just for this might be a bit overkill but we think that there might be a broader feature here. More specifically, we think it'd be cool to modify the current list commands—fh list flakes, fh list releases, etc.—and enable people to specify a specific column they'd like to see and/or a max number of results. So imagine instead of get-url you had something like this:

fh list versions nixos/nixpkgs "0.2311.*" --limit 1 --columns url

And then people can provide their own aliases and such if they want a shortcut to get-url. Does this seem like a compelling idea to you? I'd be happy to implement, so please don't feel pressured to turn this PR into something more ambitious.

Also, thank you for your kind words about the developer experience! Definitely a major priority for us and yes, aren't direnv and the rest just phenomenal?!?! Hard to imagine anything else at this point.

@rybern
Copy link
Author

rybern commented Dec 11, 2023

Sounds good Luc!

I was imagining something very short and easy to remember because in my experimentation, that felt like a basic functionality to me, but I absolutely may not be the norm. The example you gave also makes sense to me as part of the existing API.

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

Successfully merging this pull request may close these issues.

2 participants