I'm working on an arara rule that makes use of the items identifier

% arara: myrule: {items: [lions, zebras]}



hello world


The rule, myrule.yaml, looks like this:

identifier: myrule
name: myrule
- <arara> @{ isTrue( myswitch, isWindows( "cmd /c echo", "echo" ) ) } @{item}
# can I toggle myswitch here?
- identifier: myswitch
  flag: <arara> @{parameters.myswitch}
  default: true

I would like to toggle the myswitch identifier to false within the rule- how can I do this? :)

(The reason is for the rule I made for How to create individual chapter PDFs).

1 Answer 1


Sadly, it's not possible to have a switch in the rule context.

When using iterators like items/@{item} or files/@{file}, the rule is replicated to every item; the context is stateless, it has no previous memory of past expansions.

One possible dirty hack is to compare the current @{item} to a variable supplied by the directive and execute one of the commands if and only if they are equal:

identifier: myrule
name: myrule
- <arara> @{ isTrue( item == element, isWindows( "cmd /c echo", "echo" ) ) } @{item}
- identifier: element
  flag: <arara> @{parameters.element}

And in the directive:

% arara: myrule: { items: [ lions, zebras ], element: lions }

Note that element applies to the first item of the list.

With the upcoming version of arara, we might be able to perform checks in directives with something we call conditionals. We are still working on it, but so far, it looks good.

I'll think of adding a internal map containing some useful info to rulemakers, like the item count, the current item, and other goodies. Of course, it will be properly documented. :)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .