xpd new
Create a rule project, or a rule, test case or utility in one
Use xpd new to start a rule project or to add a rule, a test case or a utility to one. Run it
without a command, and it asks what to create and asks for each missing value. With --yes it
never asks, which suits scripts and agents.
xpd new [OPTIONS] [COMMAND]xpd new --help ends with these lines.
Examples: xpd new xpd new project --pack team xpd new rule team/no-iterrows --pattern '$DF.iterrows()' --message 'Loop over columns instead.' --yes xpd new rule utc-now --language python --pattern 'datetime.utcnow()' \ --fix 'datetime.now(UTC)' --fix-safety unsafe --message 'utcnow is naive.' --with-test --yes xpd new test team/no-iterrows --yes xpd new util new-figure --language python --pattern 'go.Figure($$$)' --yesCommands
Section titled “Commands”| Command | What it does |
|---|---|
xpd new project |
Create sgconfig.yml, xpd.yml and the rules, rule-tests and utils folders |
xpd new rule |
Create a rule from a pattern, with the Markdown that explains it beside the rule file |
xpd new test |
Create an empty test case for a rule, with no valid or invalid code yet |
xpd new util |
Create a global utility rule, which any rule can use with matches: <name> |
Options
Section titled “Options”--directory
Section titled “--directory”--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
Section titled “--format”--format <FORMAT>
Print the result as text, or as JSON with createdFiles and modifiedFiles.
Default: text.
Values: text, json.
Examples
Section titled “Examples”$ xpd new project --pack team --yesCreated project created /tmp/project/sgconfig.yml created /tmp/project/xpd.yml created /tmp/project/rules/.gitkeep created /tmp/project/rule-tests/.gitkeep created /tmp/project/utils/.gitkeep created /tmp/project/rules/team/.gitkeep$ xpd new rule team/no-print --pattern 'print($X)' --message 'Use the project logger.' --with-test --yesCreated rule team/no-print created /tmp/project/rules/team/no-print.yml created /tmp/project/rules/team/no-print.md created /tmp/project/rule-tests/team/no-print-test.yml$ xpd new util print-call --lang python --pattern 'print($X)' --yesCreated util print-call created /tmp/project/utils/print-call.ymlThe commands above write these files. Each folder that project makes also gets an empty
.gitkeep.
.├── sgconfig.yml # ruleDirs: rules, utilDirs: utils, testConfigs: rule-tests├── xpd.yml # the pack team, with ruleDirs: rules/team├── rules/team/no-print.yml├── rules/team/no-print.md # the Markdown that explains team/no-print├── rule-tests/team/no-print-test.yml # id: team/no-print, valid: [], invalid: []└── utils/print-call.yml--format json prints createdFiles and modifiedFiles as absolute paths.
Exit status
Section titled “Exit status”| Exit code | Meaning |
|---|---|
| 0 | The files were written |
| 2 | A value is missing with --yes, a file it would write exists, or the rule does not parse. Nothing is written |