After some copy/pasting from existing rules and research I came up with a working solution, although I am not entirely happy with it...
Instead of removing all the files from an exisiting folder, I simply delete the directory and recreate it in the same place. Empty, of course.
!config
# Rule for deleting the contents of a folder with arara
identifier: cleanfolder
name: CleaningTool for a whole folder
commands:
- <arara> @{ isWindows( "cmd /c rmdir /s/q", "rm -f" ).concat(' "').concat(folder).concat('"') }
- <arara> @{ isWindows( "cmd /c md", "mkdir").concat(' "').concat(folder).concat('"') }
arguments:
- identifier: folder
flag: <arara> @{parameters.folder}
I would be very happy with any comment on this, for I think the problem could be solved a lot more "elegantly" than with what I produced.
Update:
I even managed to address the second part of my question myself. Inspired by Chris' answer to Using arara to compile powerdot twice I modified the pdflatex rule that is shipped with arara to define some sort of switch command that triggers the desired action in the .tex file if the switch is correctly defined.
rule: pdflatexwithswitch
!config
identifier: pdflatexwithswitch
name: run PDFLaTeX with specified switch and optional value
command: <arara> pdflatex @{action} @{draft} @{shell} @{synctex} @{options} "\def\@{switchname}{@{switchvalue}}\input{@{file}}"
arguments:
- identifier: action
flag: <arara> --interaction=@{parameters.action}
- identifier: shell
flag: <arara> @{isTrue(parameters.shell,"--shell-escape","--no-shell-escape")}
- identifier: synctex
flag: <arara> @{isTrue(parameters.synctex,"--synctex=1","--synctex=0")}
- identifier: draft
flag: <arara> @{isTrue(parameters.draft,"--draftmode")}
- identifier: options
flag: <arara> @{parameters.options}
- identifier: switchname
flag: <arara> @{parameters.switchname}
- identifier: switchvalue
flag: <arara> @{parameters.switchvalue}
default: 0
The rule in action:
demo.tex
% arara: pdflatexwithswitch: { shell: yes, switchname: forceremake, switchvalue: doit }
\usepgfplotslibrary{external}
\ifthenelse{\isundefined{\forceremake}}{}{\ifthenelse{\equal{\forceremake}{doit}}{\tikzset{external/force remake}}{}}
I am much more content with this one. Comments still welcome.
mode=list and makefor the external library, which creates a makefile for generating the figures. To force the figures to be re-created, you'd need to use the-Bflag (if memory serves me right) when running the makefile. – sudosensei Mar 15 '14 at 17:20make -f demo.makefileI get an error. Any hints? – Huugo Mar 17 '14 at 15:18:-)What error are you getting? – sudosensei Mar 17 '14 at 16:32Cthan LaTeX -- weird. Maybe you should consider posting a new question? – sudosensei Mar 17 '14 at 17:29