Skip to content

feature: dune show targets and dune show aliases - #7770

Merged
rgrinberg merged 1 commit into
ocaml:mainfrom
Alizter:ps/branch/feature__dune_targets
Jun 17, 2023
Merged

rgrinberg merged 1 commit into
ocaml:mainfrom
Alizter:ps/branch/feature__dune_targets

Conversation

@Alizter

@Alizter Alizter commented May 21, 2023 •

Copy link
Copy Markdown
Collaborator

Add new dune show targets and dune show aliases commands that work similarly to ls displaying targets and aliases respectively in the current directory or instead any directories given as arguments. They do not show targets or aliases in subdirectories or inside directory targets. Directory targets will be printed with a trailing path separator to distinguish them however.

and continuing

part of general effort in:

This is quite useful in cram tests to make sure dune is willing to produce the correct targets.

  • changelog
  • docs (more cli docs too)
  • display directory targets ending with an /

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch 5 times, most recently from cd5c97c to 565e0f4 Compare May 22, 2023 18:48
@Alizter
Alizter marked this pull request as ready for review May 22, 2023 18:49
@Alizter

Alizter commented May 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

@emillon Since this is a relatively straightforward addition, it could perhaps be considered for 3.8.

Edit: Actually, nevermind. The scope has grown a bit so probably worth waiting to next major version.

@nojb

nojb commented May 22, 2023

Copy link
Copy Markdown
Collaborator

Does it make sense to display aliases as well?

@Alizter

Alizter commented May 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

@nojb I have something similar giving hints to aliases: #7004. However due to the way we lookup aliases we have to do it for all contexts at the same time. It shouldn't be too difficult to add an --aliases option that also shows which aliases are available.

I don't think I will be able to do it in this PR however, since it will need some more refactoring of how we handle aliases in bin. I'll open a feature request when this is merged however.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch 2 times, most recently from 1e936bf to 6fc8026 Compare May 22, 2023 19:37
@Alizter

Alizter commented May 22, 2023

Copy link
Copy Markdown
Collaborator Author

@nojb Actually I went ahead and implemented an --aliases option that shows aliases in addition. Is this what you had in mind?

I'm actually unsure if we want this in the targets command or we wish to have a separate command for displaying aliases. In any case if we are undecided we can always drop that commit.

@nojb

nojb commented May 22, 2023

Copy link
Copy Markdown
Collaborator

@nojb Actually I went ahead and implemented an --aliases option that shows aliases in addition. Is this what you had in mind?

I think so, yes, thanks! What I had in mind is a beginner; I would imagine most of the time such an user will be more interested in invoking an alias than a target file.

@snowleopard

snowleopard commented May 22, 2023 •

Copy link
Copy Markdown
Contributor

That's a very useful command but I feel like it shouldn't be top-level. Don't we usually put these things under dune describe?

I don't like the name "describe" and would prefer something like dune show instead, but that's a detail. I think we can end up polluting the top-level namespace if we keep adding commands like dune targets.

@nojb

nojb commented May 22, 2023 •

Copy link
Copy Markdown
Collaborator

I don't like the name "describe" and would prefer something like dune show instead, but that's a detail. I think we can end up polluting the top-level namespace if we keep adding commands like dune targets.

dune show seems like a good top-level name for this kind of functionality. Why not add dune show and put the command under it? (dune show targets). Existing commands could be migrated under it as well later: dune show rules instead of dune rules, dune show env instead of dune printenv, dune show workspace instead of dune describe workspace, etc

@snowleopard

Copy link
Copy Markdown
Contributor

dune show seems like a good top-level name for this kind of functionality. Why not add dune show and put the command under it? (dune show targets). Existing commands could be migrated under it as well later: dune show rules instead of dune rules, dune show env instead of dune printenv, dune show workspace instead of dune describe workspace, etc

@nojb Sounds like a great plan to me!

@snowleopard

Copy link
Copy Markdown
Contributor

I'm actually unsure if we want this in the targets command or we wish to have a separate command for displaying aliases. In any case if we are undecided we can always drop that commit.

@Alizter If we go with the dune show plan, then I'd prefer aliases to be handled by dune show aliases.

@rgrinberg

rgrinberg commented May 22, 2023 •

Copy link
Copy Markdown
Member

I don't like the name describe either, but I don't like to have two names for the same thing either. I'd rather teach users one bad name rather than a good name and a bad name.

@Alizter

Alizter commented May 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

@rgrinberg We can deprecate the bad name (error) and point to the new good name. I've started a proposal in #7784,

@rgrinberg

rgrinberg commented May 22, 2023 •

Copy link
Copy Markdown
Member

We shouldn't. The disturbance caused by this deprecation far outweighs whatever benefit can be gained from it. Going through a deprecating cycle is a ton of churn for both the developers and the users. At best, we can introduce an alias like we did for runtest.

@nojb

nojb commented May 22, 2023

Copy link
Copy Markdown
Collaborator

We shouldn't. The disturbance caused by this deprecation far outweighs whatever benefit can be gained from it.

Even if we don't aggressively deprecate the existing commands and just alias them under new names, I think that, in terms of CLI usability, it would still be an improvement migrating to dune show as a top-level name for all these commands. We could do a "soft" deprecation by not documenting the commands under the old names anymore, so that new users would be directed to the new names only. One could even imagine going one step further (if it is possible, I haven't checked) and remove the old names from the auto-generated dune --help page. Even if that is not possible we could clearly indicate in the help page that the dune show commands are to be preferred.

@rgrinberg

rgrinberg commented May 22, 2023 •

Copy link
Copy Markdown
Member

Before we deprecate (hard or soft) describe, let's come up with a simple explanation for why we're doing so. Hopefully something that a user can read in a change log and immediately see the benefit for himself.

Also, it would be a very poor experience to partition our subcommands into describe and show. The user would never remember which subcommand belongs to which group. So to follow the principle of least surprise, everything should be available under w/e group names are exposed.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 6fc8026 to 116dfde Compare May 22, 2023 21:45
@Alizter

Alizter commented May 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

Regarding this PR: I've added a show subcommand and added aliases and a subcommand of that. So we have dune show aliases and dune show targets. Both have tests.

I'm drafting this PR for the time being so we can continue to discuss how best to group the commands. My thinking is that we really want to add these to dune describe and we want to rename dune describe to dune show. But let's continue that discussion in the issue.

Also dune describe isn't using command groups, so we will have to do some refactoring there first.

@Alizter
Alizter marked this pull request as draft May 22, 2023 21:48
@snowleopard

Copy link
Copy Markdown
Contributor

I just want to say that this feature was requested internally (there was particular interest for dune show aliases). I wonder if we can make progress here, somehow. Maybe add these commands both into dune describe and dune show? Alternatively, add them only to dune describe for now and create a ticket to think about a possible migration story towards dune show.

@rgrinberg

Copy link
Copy Markdown
Member

I just want to say that this feature was requested internally (there was particular interest for dune show aliases). I wonder if we can make progress here, somehow

Externally, it's easy to make progress. We just follow existing conventions.

Internally, we no longer import the command line from upstream. Nor do we have an existing show or describe command internally, so we can name this whatever we like. However, we would need to factor this out into something that can be used by both command lines.

@Alizter
Alizter marked this pull request as ready for review June 16, 2023 13:41

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test generated targets (not worth investigating at this time)

What are generated targets?

Comment thread CHANGES.md Resolved
Comment thread bin/describe/aliases_cmd.ml Resolved
Comment thread bin/describe/targets_cmd.ml Resolved
Comment thread bin/describe/targets_cmd.ml Resolved
@Alizter

Alizter commented Jun 16, 2023

Copy link
Copy Markdown
Collaborator Author

test generated targets (not worth investigating at this time)

What are generated targets?

Nevermind, I was confused about something when I wrote it.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch 2 times, most recently from a37f7ec to 4480d89 Compare June 16, 2023 19:09
@Alizter Alizter changed the title feature: dune targets feature: dune show targets and dune show aliases Jun 16, 2023
@rgrinberg rgrinberg added this to the 3.9.0 milestone Jun 16, 2023
@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 4480d89 to dc39ba6 Compare June 16, 2023 21:09

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started doing some cleanups and realized there's a little too much copy pasting between aliases and targets for my tastes. Can you factor the code out?

@Alizter

Alizter commented Jun 16, 2023

Copy link
Copy Markdown
Collaborator Author

@rgrinberg sure, I'll have a look over the weekend.

@Alizter

Alizter commented Jun 17, 2023

Copy link
Copy Markdown
Collaborator Author

@rgrinberg I've factored the common code out, I'm not so sure about the API yet. I think there is some more cleanup we can do.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 6c1bbe8 to 31e3e21 Compare June 17, 2023 13:28
Comment thread bin/describe/ls_like_cmd.mli Resolved
@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch 3 times, most recently from 4114994 to 149a805 Compare June 17, 2023 14:31
@Alizter

Alizter commented Jun 17, 2023 •

Copy link
Copy Markdown
Collaborator Author

I've just added a user error for when a directory is outside of the project.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 149a805 to 4a06518 Compare June 17, 2023 15:37
@snowleopard

Copy link
Copy Markdown
Contributor

Perhaps, dune show sources could be useful too: for symmetry, and for making it possible to check which files Dune actually considers sources. (Not always obvious.)

@rgrinberg

Copy link
Copy Markdown
Member

Perhaps, dune show sources could be useful too

It could also be distinguished via some visual cue in dune show targets. We can still add dune show sources of course.

Let's save that for a subsequent PR though.

@snowleopard

Copy link
Copy Markdown
Contributor

Sure, happy for this to go to a separate PR.

@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 4a06518 to 01f4801 Compare June 17, 2023 16:16
Add a `dune show targets` and `dune show aliases` command for showing
targets and aliases in a directory like `ls`.

fix ocaml#265

Co-authored-by: Rudi Grinberg <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter force-pushed the ps/branch/feature__dune_targets branch from 01f4801 to 449d834 Compare June 17, 2023 16:52
@rgrinberg
rgrinberg merged commit 3bb078f into ocaml:main Jun 17, 2023
@Alizter
Alizter deleted the ps/branch/feature__dune_targets branch June 17, 2023 17:28
emillon added a commit to emillon/opam-repository that referenced this pull request Jun 23, 2023
CHANGES:

- Validate file extension for `$ dune ocaml top-module`. (ocaml/dune#8005, fixes ocaml/dune#8004, @3Rafal)

- Include the time it takes to read/write state files when `--trace-file` is
  enabled (ocaml/dune#7960, @rgrinberg)

- Add `dune show` command group which is an alias of `dune describe`. (ocaml/dune#7946,
  @Alizter)

- Include source tree scans in the traces produced by `--trace-file` (ocaml/dune#7937,
  @rgrinberg)

- Cinaps: The promotion rules for cinaps would only offer one file at a time no
  matter how many promotions were available. Now we offer all the promotions at
  once (ocaml/dune#7901, @rgrinberg)

- Do not re-run OCaml syntax files on every iteration of the watch mode. This
  is too memory consuming. (ocaml/dune#7894, fix ocaml/dune#6900, @rgrinberg)

- Remove some compatibility code for old version of dune that generated
  `.merlin` files. Now dune will never remove `.merlin` files automatically
  (ocaml/dune#7562)

- Add `dune show env` command and make `dune printenv` an alias of it. (ocaml/dune#7985,
  @Alizter)

- Add additional metadata to the traces provided by `--trace-file` whenever
  `--trace-extended` is passed (ocaml/dune#7778, @rleshchinskiy)

- Extensions used in `(dialect)` can contain periods (e.g., `cppo.ml`). (ocaml/dune#7782,
  fixes ocaml/dune#7777, @nojb)

- Allow `(include_subdirs qualified)` to be used when libraries define a
  `(modules ...)` field (ocaml/dune#7797, fixes ocaml/dune#7597, @anmonteiro)

- `$ dune describe` is now a command group, so arguments to subcommands must be
  passed after subcommand itself. (ocaml/dune#7919, @Alizter)

- The `interface` and `implementation` fields of a `(dialect)` are now optional
  (ocaml/dune#7757, @gpetiot)

- Add commands `dune show targets` and `dune show aliases` that display all the
  available targets and aliases in a given directory respectively. (ocaml/dune#7770,
  grants ocaml/dune#265, @Alizter)

- Allow multiple globs in library's `(stdlib (internal_modules ..))`
  (@anmonteiro, ocaml/dune#7878)

- Attach melange rules to the default alias (ocaml/dune#7926, @haochenx)

- In opam constraints, reject `(and)` and `(or)` with no arguments at parse
  time (ocaml/dune#7730, @emillon)

- Compute digests and manage sandboxes in background threads (ocaml/dune#7947,
  @rgrinberg)

- Add `(build_if)` to the `(test)` stanza. When it evaluates to false, the
  executable is not built. (ocaml/dune#7899, fixes ocaml/dune#6938, @emillon)

- Add necessary parentheses in generated opam constraints (ocaml/dune#7682, fixes ocaml/dune#3431,
  @Lucccyo)
emillon added a commit to emillon/opam-repository that referenced this pull request Jun 28, 2023
CHANGES:

- Validate file extension for `$ dune ocaml top-module`. (ocaml/dune#8005, fixes ocaml/dune#8004, @3Rafal)

- Include the time it takes to read/write state files when `--trace-file` is
  enabled (ocaml/dune#7960, @rgrinberg)

- Add `dune show` command group which is an alias of `dune describe`. (ocaml/dune#7946,
  @Alizter)

- Include source tree scans in the traces produced by `--trace-file` (ocaml/dune#7937,
  @rgrinberg)

- Cinaps: The promotion rules for cinaps would only offer one file at a time no
  matter how many promotions were available. Now we offer all the promotions at
  once (ocaml/dune#7901, @rgrinberg)

- Do not re-run OCaml syntax files on every iteration of the watch mode. This
  is too memory consuming. (ocaml/dune#7894, fix ocaml/dune#6900, @rgrinberg)

- Add `--all` option to `dune rpc status` to show all Dune RPC servers running.
  (ocaml/dune#8011, fix ocaml/dune#7902, @Alizter)

- Remove some compatibility code for old version of dune that generated
  `.merlin` files. Now dune will never remove `.merlin` files automatically
  (ocaml/dune#7562)

- Add `dune show env` command and make `dune printenv` an alias of it. (ocaml/dune#7985,
  @Alizter)

- Add additional metadata to the traces provided by `--trace-file` whenever
  `--trace-extended` is passed (ocaml/dune#7778, @rleshchinskiy)

- Extensions used in `(dialect)` can contain periods (e.g., `cppo.ml`). (ocaml/dune#7782,
  fixes ocaml/dune#7777, @nojb)

- Allow `(include_subdirs qualified)` to be used when libraries define a
  `(modules ...)` field (ocaml/dune#7797, fixes ocaml/dune#7597, @anmonteiro)

- `$ dune describe` is now a command group, so arguments to subcommands must be
  passed after subcommand itself. (ocaml/dune#7919, @Alizter)

- The `interface` and `implementation` fields of a `(dialect)` are now optional
  (ocaml/dune#7757, @gpetiot)

- Add commands `dune show targets` and `dune show aliases` that display all the
  available targets and aliases in a given directory respectively. (ocaml/dune#7770,
  grants ocaml/dune#265, @Alizter)

- Allow multiple globs in library's `(stdlib (internal_modules ..))`
  (@anmonteiro, ocaml/dune#7878)

- Attach melange rules to the default alias (ocaml/dune#7926, @haochenx)

- In opam constraints, reject `(and)` and `(or)` with no arguments at parse
  time (ocaml/dune#7730, @emillon)

- Compute digests and manage sandboxes in background threads (ocaml/dune#7947,
  @rgrinberg)

- Add `(build_if)` to the `(test)` stanza. When it evaluates to false, the
  executable is not built. (ocaml/dune#7899, fixes ocaml/dune#6938, @emillon)

- Add necessary parentheses in generated opam constraints (ocaml/dune#7682, fixes ocaml/dune#3431,
  @Lucccyo)
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.

Diagnose missing target errors

4 participants