Skip to content

xpd new util

Create a global utility rule, which any rule can use with matches: <name> Use xpd 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 new project --yes --format json | jq -c .item
"project"
$ xpd new util print-call --lang python --pattern 'print($X)' --yes
Created util print-call
created /tmp/project/utils/print-call.yml
Terminal window
xpd new util [OPTIONS] [NAME]

<NAME>

The utility's name, which rules use as matches: <name>.

-l, --language <LANGUAGE>

The language of the code the utility matches.

Also written --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>

Print the result as text, or as JSON with createdFiles and modifiedFiles.

Default: text.

Values: text, json.