Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm working on an arara rule for indent.plx which can be called in a few different ways:

  • indent.plx myfile.tex (outputs to the terminal)
  • indent.plx -w myfile.tex (overwrites original file and outputs to terminal)
  • indent.plx -o myfile.tex outputfile.tex (outputs to a separate file and outputs to terminal)
  • indent.plx -s myfile.tex (silent mode, no ouptput to terminal)

I'd like to wrap up these choices (and others, hopefully) in one tidy arara rule. So far I have

!config
# indent rule for arara
# author: cmhughes
# requires arara 3.0+
#
# Sample use:
# % arara: indent
# % arara: indent: {overwrite: true}
# % arara: indent: {overwrite: on}
# % arara: indent: {overwrite: yes}
# % arara: indent: {overwrite: false}
#
identifier: indent
name: Indent
command: indent.plx @{overwrite} "@{file}"
arguments:
- identifier: overwrite
  flag: <arara> @{ isTrue( parameters.overwrite, "-w","" ) }

How can I extend my rule to include the other options to output to a separate file and for silent mode?

I'd like to be able to use, for example, each of the following

% arara: indent: {overwrite: false, outputFile: outputfile.tex}
% arara: indent: {outputFile: outputfile.tex, silent: true}
share|improve this question
    
Got it working in windoze 7 :-). –  Harish Kumar Mar 24 '13 at 6:47
    
@HarishKumar superb, that's great news! I might call on you for some details before I release it :) –  cmhughes Mar 24 '13 at 15:56
add comment

1 Answer

up vote 10 down vote accepted
+200

I'll make a humble attempt. :)

First, let's define which directive arguments we might use:

  • silent: it holds a boolean value (in the arara context, it can be on/off, yes/no, true/false, and 0/1), which expands to -s if present and true. This is an independent argument.

  • overwrite: it also holds a boolean value, which expands to -w if present and true. This argument has an impact on the next argument (output), which invalidates its use when present and true, that is, overwriting the file has higher priority than generating an output to another file.

  • output: it holds any value which will be the output generated by the script. Only if the overwrite is absent or resolves to false, this value will be available, if not empty.

Currently, indent.plx requires -o <original file> <new file>. I mentioned to Chris in the chatroom that would be nice to have the <new file> value near to its corresponding flag -o. Two rules, one for each situation, are presented.

Requiring, e.g, indent.plx -o outputfile.tex myfile.tex:

!config
# indent rule for arara
# author: cmhughes
# requires arara 3.0+
identifier: indent
name: Indent
command: indent.plx @{silent} @{ isEmpty( overwrite, isNotEmpty( output, "-o ".concat('"').concat(output).concat('"') ), overwrite ) } "@{file}"
arguments:
- identifier: overwrite
  flag: <arara> @{ isTrue( parameters.overwrite, "-w" ) }
- identifier: silent
  flag: <arara> @{ isTrue( parameters.silent, "-s" ) }
- identifier: output
  flag: <arara> @{ parameters.output }

Requiring, e.g, indent.plx -o myfile.tex outputfile.tex:

!config
# indent rule for arara
# author: cmhughes
# requires arara 3.0+
identifier: indent
name: Indent
command: indent.plx @{silent} @{ isEmpty( overwrite, isNotEmpty( output, "-o"  ), overwrite ) } "@{file}" @{ isEmpty( overwrite, isNotEmpty( output, '"'.concat(output).concat('"') ) ) }
arguments:
- identifier: overwrite
  flag: <arara> @{ isTrue( parameters.overwrite, "-w" ) }
- identifier: silent
  flag: <arara> @{ isTrue( parameters.silent, "-s" ) }
- identifier: output
  flag: <arara> @{ parameters.output }

Then we can use the following directives:

% arara: indent: { overwrite: false, output: outputfile.tex }
% arara: indent: { output: outputfile.tex, silent: true }
% arara: indent: { overwrite: true, silent: yes }

There we go! :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.