Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ users)
## Pin

## List
* Add `license` as a possible field name in the columns argument [#6841 @raphael-proust]

## Show
* Improve performance of `opam show` by reading switch selection only once instead of once per package-version [#6818 @dra27]
Expand Down
8 changes: 8 additions & 0 deletions src/client/opamListCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ type output_format =
| Field of string
| Raw_field of string
| Installed_version
| License
| Pinning_target
| Source_hash
| Raw
Expand All @@ -452,6 +453,7 @@ let disp_header = function
| Description -> "Description"
| Field s | Raw_field s -> String.capitalize_ascii s
| Installed_version -> "Installed"
| License -> "License"
| Pinning_target -> "Pin"
| Source_hash -> "Source hash"
| Raw -> "Metadata"
Expand All @@ -473,6 +475,7 @@ let field_names = [
Field "<field>", "<field>";
Raw_field "<field>:", "<field>:";
Installed_version, "installed-version";
License, "license";
Pinning_target, "pin";
Source_hash, "source-hash";
Raw, "opam-file";
Expand Down Expand Up @@ -624,6 +627,11 @@ let detail_printer ?prettify ?normalise ?(sort=false) installed st nv =
then s % [`bold;`yellow] else
s % [`magenta]
with Not_found -> "--" % [`cyan])
| License ->
(try mini_field_printer
(OpamStd.List.assoc String.equal "license"
(OpamFile.OPAM.to_list (get_opam st nv)))
with _ -> "--" % [`cyan])
| Pinning_target ->
if OpamPackage.Set.mem nv st.pinned then
let opam = get_opam st nv in
Expand Down
1 change: 1 addition & 0 deletions src/client/opamListCommand.mli
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type output_format =
| Field of string (** The value of the given opam-file field *)
| Raw_field of string (** The raw value of the given opam-file field *)
| Installed_version (** Installed version or "--" if none *)
| License (** License or "--" if not found *)
| Pinning_target (** Empty string if not pinned *)
| Source_hash (** The VC-reported ident of current version, for dev
packages. Empty if not available *)
Expand Down
21 changes: 21 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,27 @@
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:list-coinstallable.test} %{read-lines:testing-env}))))

(rule
(alias reftest-list-format)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(action
(diff list-format.test list-format.out)))

(alias
(name reftest)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(deps (alias reftest-list-format)))

(rule
(targets list-format.out)
(deps root-N0REP0)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) (= %{env:TESTN0REP0=0} 1))))
(package opam)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{exe:../../src/client/opamMain.exe.exe} %{dep:list-format.test} %{read-lines:testing-env}))))

(rule
(alias reftest-list-large-dependencies)
(enabled_if (and (or (<> %{env:TESTALL=1} 0) )))
Expand Down
Loading