# Subcommand show-dependencies

**URL:** <https://discourse.pijul.org/t/subcommand-show-dependencies/18>\
**Category:** Development\
**Created:** [June 1, 2017, 6:56am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18 "2017-06-01T06:56:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 1, 2017, 6:56am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/1 "2017-06-01T06:56:28Z")

</div>

H there.

Yesterday, I have pushed yesterday [a first patch](https://nest.pijul.com/pijul_org/pijul/patches/AfJfh8KNbsUY3F43Zt-AX9kL7SiIwgwv7o9WN85zOdDGNc4DZw13alANY-9thFoOKyBWPj1t63PHeavGWxH2-0g) to introduce a new subcommand, that is `show-dependencies`. The goal is to output a `.dot` files which can be rendered with `dot -Tpng` for instance.

The first version of this subcommand takes the same arguments as `pijul changes`. My goal is to add several other way to use it, such as:

- `--hash <hash>` to only print one patch and its direct dependencies
- `--hash <hash> --depth <x>`, same as before, but recursively with `x` levels

Do you have other ideas or wishes?

---

<div class="post-metadata">

**Author:** ![joeneeman](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/joeneeman/32/77_2.png) [@joeneeman](https://discourse.pijul.org/u/joeneeman)\
**Post date:** [June 1, 2017, 7:21am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/2 "2017-06-01T07:21:00Z")

</div>

Great! I’d prefer it without the `--hash` argument, so that `pijul show-dependencies <hash>` would show the dependencies of that patch. That would be consistent with `pijul apply`.

---

<div class="post-metadata">

**Author:** ![joeneeman](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/joeneeman/32/77_2.png) [@joeneeman](https://discourse.pijul.org/u/joeneeman)\
**Post date:** [June 1, 2017, 7:25am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/3 "2017-06-01T07:25:05Z")

</div>

By the way, I know all the other commands do it, but I think

```
let target = find_repo_root(&wd).ok_or(Error::NotInARepository)?;

```

is better than the match statement. For example, it saves two levels of indentation for the bulk of the function.

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 1, 2017, 7:54am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/4 "2017-06-01T07:54:57Z")

</div>

(FYI, you can edit your post on discourse. It is the pen button at the bottom of your message)

Thanks for your feedback!

I would agree if `<hash>` is optional and if the tool print the whole graph in case of its absence.

And thanks for the tip, I am still a little rusty with the Rust language, I didn’t write any program for two years, so any advice is welcome.

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [June 1, 2017, 8:11am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/5 "2017-06-01T08:11:17Z")

</div>

Completely agree - I have caught myself a couple of times going through the `commands/*.rs` files just to rewrite that match statement 😄

---

<div class="post-metadata">

**Author:** ![joeneeman](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/joeneeman/32/77_2.png) [@joeneeman](https://discourse.pijul.org/u/joeneeman)\
**Post date:** [June 1, 2017, 2:41pm UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/6 "2017-06-01T14:41:45Z")

</div>

> [@lthms](#):
>
> I would agree if \<hash\> is optional and if the tool print the whole graph in case of its absence.

That’s the most intuitive behavior, IMO.

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 1, 2017, 5:29pm UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/7 "2017-06-01T17:29:13Z")

</div>

I will do that, then, and push accordingly.

@pmeunier @flobec: I think you can merge @joeneeman patches before mine. I saw he has made some refactoring on how commands are implemented and I can adapt my code to that “new way” before my patch is merged.

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 3, 2017, 9:24pm UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/8 "2017-06-03T21:24:22Z")

</div>

So I push a complete and functional version of `show-dependencies` to the Nest. I use the opportunity to fix a conflict in `graph.rs` (in a second patch).

@laumann I totally forgot your suggestion… I am very sorry about that.

@pmeunier @flobec The patches are:

- [The show-dependencies command](https://nest.pijul.com/pijul_org/pijul/patches/AW5CEahn7WOqj0Xz1vWPF5stl3npgC6_iWqNlnN3WJYeYJDPZx-74L3XXm102Dfqkhop347e3URm9XujJPtclEY)
- [The libpijul conflict](https://nest.pijul.com/pijul_org/pijul/patches/ASNMfut3sAOk9b7ZKKYj9bhQUeU0oxnkrpD62JTmEejaQK9WizpBwqiGC3xL3OP6Lw3ZNMRdzgxt9PUnQcXmYtI)

Do you have a way to refuse/discard the two other patches I have pushed before and are now irrelevant (sorry about that)?

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [June 4, 2017, 8:11am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/9 "2017-06-04T08:11:27Z")

</div>

No worries, my input was only stylistic anyways 🙂

I had a few more stylistic considerations: The `label_sanitize()` function caught my eye. From where it’s used, shouldn’t it be possible to do:

```auto
fn label_sanitize(name: &String) -> String {
    name.replace("\"", "\\\"")
}

```

and then

```auto
label_sanitize(&patch.header().name)

```

to avoid cloning `name`? A similar consideration might apply for `hash_sanitize`.

It also surprised me to read:

```auto
let target = &find_repo_root(&wd).ok_or(Error::NotInARepository)?;
let repo_dir = pristine_dir(target);

```

vs

```auto
let target = find_repo_root(&wd).ok_or(Error::NotInARepository)?;
let repo_dir = pristine_dir(&target);

```

I think the second form is more idiomatic, but that’s just my opinion 🙂

---

<div class="post-metadata">

**Author:** ![laumann](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/laumann/32/8_2.png) [@laumann](https://discourse.pijul.org/u/laumann)\
**Post date:** [June 4, 2017, 8:14am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/10 "2017-06-04T08:14:07Z")

</div>

Oh, and another stylistic thing. Instead of

```auto
String::from("foo")

```

consider

```auto
"foo".to_owned()

```

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 4, 2017, 10:03am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/11 "2017-06-04T10:03:44Z")

</div>

Thanks! I will try to address that and, this time, will come back to you all before pushing to the nest. I was eager to finish that, sorry.

---

<div class="post-metadata">

**Author:** ![lthms](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/lthms/32/124_2.png) [@lthms](https://discourse.pijul.org/u/lthms)\
**Post date:** [June 5, 2017, 8:50am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/12 "2017-06-05T08:50:21Z")

</div>

Yet another version of the patch [here](https://nest.pijul.com/lthms/pijul/patches/AdgcJy8XgxOwwhPPbCVOtobUQWoJ2WUcl6BIRZ8iQtEbGxAxkzqW4AYloC6bLki6R9NDqk83tUkPU5oBVLCHKw8). Thanks again for you help, everyone.

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [September 18, 2025, 11:54am UTC](https://discourse.pijul.org/t/subcommand-show-dependencies/18/13 "2025-09-18T11:54:16Z")

</div>


