CLI¶
phileas includes a command-line interface (CLI) that lets you redact sensitive information from text directly from your terminal — no Python code required.
Installation¶
The CLI is installed automatically with the phileas package:
After installation, the phileas command is available in your shell.
Usage¶
Required arguments¶
| Argument | Short | Description |
|---|---|---|
--policy FILE |
-p |
Path to a policy file (JSON or YAML). |
--context CONTEXT |
-c |
Context name used for referential integrity across documents. |
--text TEXT |
-t |
Text to redact, supplied directly as a string. Mutually exclusive with --file. |
--file FILE |
-f |
Path to a file whose contents should be redacted. Mutually exclusive with --text. |
Optional arguments¶
| Argument | Short | Description |
|---|---|---|
--document-id ID |
-d |
Document identifier. Auto-generated if omitted. |
--output FILE |
-o |
Write the redacted text to FILE instead of stdout. |
--spans |
Print span metadata as JSON to stderr after filtering. | |
--evaluate FILE |
Path to a JSON file containing ground-truth spans. Prints evaluation metrics (precision, recall, F1) to stdout. |
Policy files¶
The --policy argument accepts a path to a JSON or YAML policy file. The file must conform to the phileas policy schema.
JSON policy file example¶
{
"name": "my-policy",
"identifiers": {
"emailAddress": {
"emailAddressFilterStrategies": [
{"strategy": "REDACT", "redactionFormat": "{{{REDACTED-%t}}}"}
]
},
"ssn": {
"ssnFilterStrategies": [
{"strategy": "REDACT", "redactionFormat": "{{{REDACTED-%t}}}"}
]
}
}
}
YAML policy file example¶
name: my-policy
identifiers:
emailAddress:
emailAddressFilterStrategies:
- strategy: REDACT
redactionFormat: "{{{REDACTED-%t}}}"
ssn:
ssnFilterStrategies:
- strategy: REDACT
redactionFormat: "{{{REDACTED-%t}}}"
Examples¶
Redact a text string¶
Output:
Redact the contents of a file¶
The redacted text is written to stdout.
Write redacted output to a file¶
Use a YAML policy file¶
Supply a custom document ID¶
View span metadata¶
Use --spans to print details about each detected piece of sensitive information as JSON on stderr:
Stdout:
Stderr:
[
{
"characterStart": 6,
"characterEnd": 22,
"filterType": "email-address",
"text": "john@example.com",
"replacement": "{{{REDACTED-email-address}}}",
"confidence": 1.0,
"ignored": false,
"context": "my-context"
}
]
Pipe text from another command¶
Pass a file to phileas with the --file flag:
Evaluate against ground-truth annotations¶
Use --evaluate to compare the filter's output against a JSON file of ground-truth spans. Evaluation metrics are printed to stdout after the redacted text.
The ground-truth JSON file must be either a JSON array of span objects or a JSON object with a "spans" key. Each span must have "start" and "end" character positions, and an optional "type" field:
Or using the object format:
{
"text": "Email john@example.com.",
"spans": [
{"start": 6, "end": 22, "type": "email-address"}
]
}
Stdout (redacted text followed by metrics):