Skip to content

xpd rules new util

Use xpd rules new util to add a utility rule, which any rule of the project can use with matches: <name>. It goes to the first folder that utilDirs in sgconfig.yml names.

Terminal window
$ xpd rules new project --yes --format json | jq -c .item
"project"
$ xpd rules new util print-call --lang python --pattern 'print($X)' --yes
Created util print-call
created /tmp/project/utils/print-call.yml
Terminal window
xpd rules new util [OPTIONS] [NAME]
Argument What it does
<NAME> The utility's name, which rules use as matches: <name>.
Option Default What it does
-l, --language <LANGUAGE> The language of the code the utility matches. Aliases: --lang. Values: bash, c, cpp, csharp, css, dart, elixir, go, haskell, hcl, html, java, javascript, json, kotlin, lua, markdown, nix, php, python, ruby, rust, scala, solidity, swift, tsx, typescript, yaml, zig.
-p, --pattern <PATTERN> The code the utility matches.
--directory <DIR> The project folder, which holds sgconfig.yml. Nothing is written outside it. Default: the nearest folder at or above the current one with sgconfig.yml, or the current folder for a new project.
-y, --yes Never ask. Fail when a required flag is missing.
--format <FORMAT> text Print the result as text, or as JSON with createdFiles and modifiedFiles. Values: text, json.