opam icon indicating copy to clipboard operation
opam copied to clipboard

Add `opam repo show <reponame>` support

Open ProgramingIsTheFuture opened this issue 4 months ago • 4 comments

Related to issue https://github.com/ocaml/opam/issues/6235.

Adding a new command that will allow us to get the URL and Rank of a specific repo.

Also supports all (will display the url and rank of a repo for every switch):

$ opam repo show default --all

ProgramingIsTheFuture avatar Oct 05 '25 11:10 ProgramingIsTheFuture

(sorry, I can't get past .. as meaning the parent directory!)

dra27 avatar Oct 06 '25 13:10 dra27

There are some other commands with the same behaviour (abc is not defined):

$ opam repo list --switch=abc
[NOTE] These are the repositories in use by the current switch. Use '--all'
       to see all configured repositories.

<><> Repository configuration for switch abc <><><><><><><><><><><><><><><><>
 1 default https://opam.ocaml.org

Reading more the code, I found that the actual flag to select switch is --on-switch (defined here). This will produce the expected behaviour (error in case of non-existing switch).

Because --switch=<switch> doesn't populate the `Switch <switch>: https://github.com/ocaml/opam/blob/ce734b35a18bc98642f7212a280dc4d6c64c969f/src/client/opamCommands.ml#L2375-L2383

Could you please verify?

ProgramingIsTheFuture avatar Oct 07 '25 11:10 ProgramingIsTheFuture

Ah my bad, i thought --switch would do it without looking at the man page because of the name of the variant. --on-switch works as expected indeed.

I think we should fix --switch separately. I'll open a ticket.

kit-ty-kate avatar Oct 07 '25 12:10 kit-ty-kate

Hey @kit-ty-kate, I made the above changes.

Wait for switch, then parse each line in this context until a new line starting with switch: ?

Yes, the output should be a name, url and rank.

It now works with -a and without repo_name (it will list all repos for the current switch) and the error message is better now.

ProgramingIsTheFuture avatar Oct 21 '25 15:10 ProgramingIsTheFuture