just icon indicating copy to clipboard operation
just copied to clipboard

List available recipes as a graph or tree

Open tducret opened this issue 2 years ago • 4 comments

Hi there! Is there a way to quickly check the recipe dependencies? I checked the Listing Available Recipes page but it's not mentioned.

If not existing, I think it could be worth to implement. Let's take an example. Based on this Justfile found in the documentation :

# Justfile
a:
  echo 'A!'

b: a
  echo 'B start!'
  just c
  echo 'B end!'

c:
  echo 'C!'

We could execute the following command :

just --list --graph

And we could clearly see the recipe dependencies :

├── a
├── b
│   ├── a
│   └── c
└── c

What do you think?

tducret avatar Jan 18 '24 09:01 tducret

Love this idea! I think calling it just --tree would be good, similar to the CLI tree command that prints a directory tree.

casey avatar Jan 18 '24 19:01 casey

Displaying calls like "just c" as a dependency in the tree can be difficult. What to do in a case:

bin := "just" // it can be a conditional here
a:
   echo "a"
    {{bin}} b
b:
  echo "b"

or in this case:

section := if windows { "build-win" } else { "build-lin" }
a:
   just {{section}}
  echo "Done"
build-win:
  ...
build-lin:
  ...

I can think of more complex cases, but even these ones are tricky.

VladimirMarkelov avatar Jan 18 '24 19:01 VladimirMarkelov

Oh sorry, I missed that part. Yeah, I think that displaying dependencies which are called inside recipes is not possible.

casey avatar Jan 18 '24 19:01 casey

Oh sorry, I missed that part. Yeah, I think that displaying dependencies which are called inside recipes is not possible.

Perhaps we adjust the definition of dependency a bit? To me, lah := "blah" is an assignment statement, which shouldn't be a dependency, right? Otherwise, this idea has flopped since assignments are (almost) always used in recipes.

Can you consider this point too?

gyreas avatar Apr 22 '24 21:04 gyreas