Skip to content

CLI Schema

Schemas define the expected structure of your sheet's columns. They are optional — if omitted, all columns are treated as strings.

When provided, the schema enables type validation and column aliasing.


Schema Sources

You must use only one schema source at a time. Mixing sources will produce an error.

1. Schema File

Point to a JSON file containing an array of schema definitions:

bash
holysheets read find-many \
  --spreadsheet-id <ID> \
  --sheet <sheet-name> \
  --schema-file ./schema.json

schema.json:

json
[
  { "key": "nome_estabelecimento", "type": "string" },
  { "key": "rating", "type": "number" },
  { "key": "visitado_em", "type": "date", "nullable": true }
]

2. Inline JSON

Pass the schema directly as a JSON string:

bash
holysheets read find-many \
  --spreadsheet-id <ID> \
  --sheet <sheet-name> \
  --schema-json '[{"key":"name","type":"string"},{"key":"rating","type":"number"}]'

3. Repeatable Flags

Define the schema field by field using grouped flags:

bash
holysheets read find-many \
  --spreadsheet-id <ID> \
  --sheet <sheet-name> \
  --schema-field nome_estabelecimento --schema-type string \
  --schema-field rating --schema-type number \
  --schema-field visitado_em --schema-type date --schema-nullable

Flag Grouping Rules

Each --schema-field starts a new schema block. The following flags apply to the most recent --schema-field:

FlagDescriptionRequired
--schema-fieldColumn name (starts a new block)Yes
--schema-typeData typeYes
--schema-nullableAllow null values (boolean flag)No
--schema-aliasRename the field in the outputNo

Supported Types

TypeDescription
stringText value
numberNumeric value
booleanBoolean value
dateDate value

Alias Example

Use --schema-alias to rename columns in the output:

bash
holysheets read find-many \
  --spreadsheet-id <ID> \
  --sheet <sheet-name> \
  --schema-field nome_estabelecimento --schema-type string --schema-alias name \
  --schema-field rating --schema-type number

Released under the MIT License.