为 arara 4.0 编写自定义规则

为 arara 4.0 编写自定义规则

动机:我想在每次运行之前复制一个文件foo.bar\jobname.bar所以pdflatex我想,我可以修改现有arara规则。

我想尝试这个答案中的hello.yaml规则:ararahttps://tex.stackexchange.com/a/119246/36296

!config
# Hello world
# author: Chris Hughes, Paulo Cereda
# last edited by: cmh, June 14th 2013
# requires arara 3.0+
#
# Sample usage: 
#
# % arara: hello
# % arara: hello: {name: A.Ellett}
#
# This rule is really just a shortcut for commands like the following
#
#   hello
# or
#   hello A.Ellett
#
identifier: hello
name: hello
commands: 
- <arara> bash -i -c hello @{name}
arguments: 
- identifier: name
  flag: <arara> @{parameters.name}
  default: "world"

但如果我尝试用这个规则来运行

% arara: hello

在我的.tex文件中,我收到以下错误消息:

I have spotted an error in rule 'hello' located at
'<path to arara>/rules'. I could not parse the rule,
something bad happened. Apparently, the provided YAML file is
invalid. I will do my best to help you in any way I can. There
are more details available on this exception:

DETAILS ---------------------------------------------------------
Cannot create property=commands for
JavaBean=com.github.cereda.arara.model.Rule@55a1c291
 in
'reader', line 1, column 1:
    !config
    ^
No single argument
constructor found for class
com.github.cereda.arara.model.RuleCommand
 in 'reader', line 21,
column 1:
    -   <arara> bash -i -c hello @{name}
    ^

(我替换了<path to arara>上面的消息,因为原始消息包含我的用户名;我arara在同一位置有其他自定义 .yaml 文件,它们可以完美运行)

bash 函数本身似乎有效。如果我这样做

bash -i -c hello sam

在终端内,我得到

你好,山姆!

正如预期的那样。

我正在使用arara 4.0。有什么想法可能出错了吗?

答案1

我认为你实际上想要这样的东西:

!config
# Hello world
# author: Chris Hughes, Paulo Cereda
# last edited by: cmh, June 14th 2013
# requires arara 3.0+
#
# Sample usage: 
#
# % arara: hello
# % arara: hello: {name: A.Ellett}
#
# This rule is really just a shortcut for commands like the following
#
#   hello
# or
#   hello A.Ellett
#
identifier: hello
name: hello
commands: 
- command: <arara> bash -i -c hello @{name}
arguments: 
- identifier: name
  flag: <arara> @{parameters.name}
  default: "world"

答案2

你不想要这样的东西吗?

!config
# Hello world
# author: Chris Hughes, Paulo Cereda
# last edited by: cmh, June 14th 2013
# requires arara 3.0+
#
# Sample usage: 
#
# % arara: hello
# % arara: hello: {name: A.Ellett}
#
# This rule is really just a shortcut for commands like the following
#
#   hello
# or
#   hello A.Ellett
#
identifier: hello
name: hello
command: <arara> bash -i -c hello @{name}
arguments:
- identifier: name
  flag: <arara> @{parameters.name}
  default: "world"
# vim: set nospell:

相关内容