# Pre-record hook

**URL:** <https://discourse.pijul.org/t/pre-record-hook/68>\
**Category:** Development\
**Created:** [August 26, 2017, 3:56pm UTC](https://discourse.pijul.org/t/pre-record-hook/68 "2017-08-26T15:56:59Z")\
**Posts on this page:** 9\
**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:** [August 26, 2017, 3:56pm UTC](https://discourse.pijul.org/t/pre-record-hook/68/1 "2017-08-26T15:56:59Z")

</div>

Hi everyone. I start using `pijul` again and I was thinking that a cool feature would be to be able to specify a bunch of script to run when recording; the idea is the record would fail in case one of the scripts does not return `0`.

Would you like to see something like that added to pijul? I think it is fairly easy to add, by extending `.pijul/meta.toml`.

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [August 26, 2017, 4:14pm UTC](https://discourse.pijul.org/t/pre-record-hook/68/2 "2017-08-26T16:14:22Z")

</div>

I’d love to have that, maybe in the form of a command / list of commands passed to the current shell?

---

<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:** [August 26, 2017, 5:30pm UTC](https://discourse.pijul.org/t/pre-record-hook/68/3 "2017-08-26T17:30:41Z")

</div>

We could start with something like

```auto
[hooks]
pre = [ "cmd", "args1", "args2",
        "make", "rule"
      ]

```

And we could work on that latter to give a more user friendly way to configure it.

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [August 26, 2017, 5:54pm UTC](https://discourse.pijul.org/t/pre-record-hook/68/4 "2017-08-26T17:54:00Z")

</div>

Another way to get the same result (vector of vectors of commands + arguments) from a string, in a user-friendly way, would be:

```auto
let commands:Vec<Vec<_>> = s.split(';').map(|cmd| cmd.split(' ').collect()).collect();

```

---

<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:** [August 26, 2017, 7:35pm UTC](https://discourse.pijul.org/t/pre-record-hook/68/5 "2017-08-26T19:35:02Z")

</div>

I’ve pushed a first patch which implements [a very basic support for hooks](https://nest.pijul.com/lthms/pijul/patches/ARc-JlIrjLzULv3rtQ6NGQg34quT4wEkIRhFNftJyjB0HA2uGuzXXKUTrsbp3Qyjc1xkA0zVlM5eUxZ98zAPT_A).

**Edit:** Okay so I have created a [discussion on the nest](https://nest.pijul.com/pijul_org/pijul/discussions/152) with two patches attached. As a side note, there is an issue with the UI to attach a patch. By default, after selecting the correct patch, nothing happens when clicking on submit (except the selection is lost). However, I have noticed that the source repository is by default ogma, which is the last I have created. Once I select pijul, I was able to attached my patch (but the UI was confusing: the selector has been reset to ogma, but pijul appeared right after it).

(@laumann, you may want to try on your discussion about the conflicts to verify you have the same behaviour)

It is not very clear, but I hope it can help anyway.

**Edit again:** okay, pushed a new patch, it’s on the nest discussion.

---

<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:** [August 28, 2017, 8:31am UTC](https://discourse.pijul.org/t/pre-record-hook/68/6 "2017-08-28T08:31:33Z")

</div>

Thanks! I’d like to wait for the current [conflict with Cargo.lock](https://nest.pijul.com/pijul_org/pijul/discussions/153) to be resolved, before trying this out.

---

<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:** [August 28, 2017, 8:37am UTC](https://discourse.pijul.org/t/pre-record-hook/68/7 "2017-08-28T08:37:35Z")

</div>

It makes sense, yes. If there is an issue in the patch dependencies computation, we should try not to mess with the dependency graph any further.

Before applying the patch, I want to do the following:

- Add “patch name” hooks (to check if a patch name is well-formed thanks to a script)
- Add some documentation (man pages would be great)

---

<div class="post-metadata">

**Author:** ![maxwell](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/maxwell/32/598_2.png) [@maxwell](https://discourse.pijul.org/u/maxwell)\
**Post date:** [April 4, 2024, 9:49am UTC](https://discourse.pijul.org/t/pre-record-hook/68/8 "2024-04-04T09:49:51Z")

</div>

Hello, I was wondering if anything like this every got added.

My use-case is tracking jupyter notebooks with pijul. I have a script that clears all the cell outputs, which I want to be able to run before record.

🙂

---

<div class="post-metadata">

**Author:** ![ryanbooker](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/ryanbooker/32/561_2.png) [@ryanbooker](https://discourse.pijul.org/u/ryanbooker)\
**Post date:** [April 5, 2024, 11:32am UTC](https://discourse.pijul.org/t/pre-record-hook/68/9 "2024-04-05T11:32:58Z")

</div>

In the project’s `.pijul/config` file it is possible to add a `hooks` section with a pre record hook.

e.g.

```auto
[hooks]
record = ["cargo fmt"]

```
