form0-cli
v0.1.3
Published
Command-line interface for form0 ecosystem.
Maintainers
Readme
form0-cli
[!WARNING] form0 is in active, very early development. Do not use in production. Expect breaking changes and unstable behavior.
form0-cli is the interactive command-line toolkit for building, validating, previewing, and serving schemas in the form0 open-source ecosystem. It powers the local development workflow for form0 projects.
🗂️ Documentation
- Quickstart: https://docs.form0.dev/getting-started/quickstart
- Edit your first schema: https://docs.form0.dev/getting-started/schema-edit
- Full docs: https://docs.form0.dev
⚙️ Installation
Install the CLI globally to get the form0 command:
npm install -g form0-cliOr run without a global install:
npx form0-cli🚀 Quickstart
Start the interactive shell:
form0Initialize a standard project:
- Run
init - Choose Standard project
- Let the CLI auto-load your schema (if it is the only schema in the project root)
- Run
Start the dev server:
form0> serveOpen the live preview at
http://localhost:3030(or the port printed in the terminal).
What you get in a Standard project:
form.schema.jsonwith a starter formform0.config.jsfor CLI settingstest.jsfor local engine checkssupporting-images/for field assetspackage.jsonandREADME.mdscaffolding
✏️ Edit your first schema
This workflow assumes the dev server is running (serve) and the live preview is open.
Enter schema edit mode:
form0(server)> schema editEditor required: set
EDITORorVISUAL(for example,export EDITOR=code).Preview the schema:
form0(server,schema)> previewAdd a NumericField after a field by row id:
form0(server,schema)> add NumericField after <id>Example template:
{ "data_name": "quantity", "label": "Quantity", "min": 1, "max": 100, "format": "integer" }Add a CalculatedField after the new field:
form0(server,schema)> add CalculatedField after <new-id>Example template:
{ "data_name": "total", "label": "Total", "display": { "style": "numeric" }, "calculate": "$quantity * 2" }Save and close your editor. The schema is saved and validated automatically.
Exit schema edit mode:
form0(server,schema)> qStop the dev server:
form0(server)> serve stop
Command reference summary
Interactive shell (form0)
init [dir]- Initialize a project (Standard/Web/Mobile)load/load <file>- Interactive load or load a specific schema filepreview- Show the schema summaryvalidate- Validate the current schemarun [--values <input>]- Run the engine with optional valueswatch [--auto-run] [--auto-validate]- Watch schema changesserve [--app] [--port] [--host]- Start live preview;--appruns the app dev server fromform0.config.jsschema edit- Open the schema editorschema import <csv> [--force]/schema export [csv] [--force]- Convert JSON ↔ CSVschema keys- Generate missing field keystest [dir]- Run the test.js file in a projectconnector <action>- Manage connectors (install/configure/test/reload/status/remove/uninstall/list)values/fields- Show stored values or valid field namesreload- Reload the current schema filestatus- Show the current session statusclear/clear values- Clear screen or stored valuestheme [name]/locale [name]- View or change theme/localehelp/exit- Help or quit
Standalone commands
form0 init [dir]
form0 validate <schema>
form0 preview <schema>
form0 run <schema> --values <json|string|file>
form0 watch [schema] --auto-run --auto-validate
form0 serve [schema] --port 3030 --host localhost --app
form0 schema import <csv> [-o <json>] [-f]
form0 schema export [csv] [-i <json>] [-f]
form0 test [dir]
form0 connector <action> [name]
form0 theme [name]
form0 locale [name]
form0 interactive # or: form0 shellWorking with values
form0-cli accepts JSON strings or files for --values:
form0 run form.schema.json --values '{"name":"Alice","age":25}'
form0 run form.schema.json --values values.json
form0 run form.schema.json --values values.yamlInvalid fields are filtered out with warnings based on the schema.
Requirements
- Node.js 18+
Related repositories
- form0-core - Core form engine
- form0-react - React components
- form0-react-native - React Native components
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
