CLI interface · 0.8.1

CLI: fields, constraints and presentation

Add and change fields, enable search, and configure Markdown or images.

On this page

Field commands define data types, constraints and form presentation. For example, add text, a status and a unique article address:

admingen-cli --path ./docs-demo field add Article body --type text --required
admingen-cli --path ./docs-demo field add Article status --type enum --enum draft,published --required
admingen-cli --path ./docs-demo field add Article slug --type string --required --unique

field is shorthand for entity field; both forms change the same model. Review the plan after editing: uniqueness, a type change and relationship settings can affect existing data.

Choose a type and required status

string is suitable for a short string and text for longer text. int and int64 store integers; float stores fractional numbers with the usual floating-point limitations. bool is true/false, UUID is an identifier, date is a calendar day, and datetime is a point in time.

Enum limits the set of values. JSON stores a JSON value, but does not create an arbitrary typed form. image and gallery have separate settings.

--required makes a value required; --nullable allows storing null. These are different properties. With supported autogeneration, the database or a value generator supplies the identifier. The required/default/autogeneration settings must be consistent rather than all enabled at once.

For ordinary fields, adding a Required column with --required or enabling it through field update does not require filling historical rows first. After generation and migration, old values may be null, while creates and saves enforce the current requirements. Separate restrictions on new Unique columns, primary/foreign keys and type changes still apply. See migrations.

Change a single property

admingen-cli --path ./docs-demo field update Article body --title "Текст статьи"
admingen-cli --path ./docs-demo field update Article slug --readonly=true
admingen-cli --path ./docs-demo field update Article slug --readonly=false

Update changes only the supplied properties. Use =false to disable a boolean parameter. An empty string can clear a setting that supports clearing, provided the resulting model remains valid.

A regular update/new-name does not rename a persisted field. Use Rename with preview and revisions. Deleting and recreating a field is not the same as renaming it while preserving data.

How parameters affect the interface and API

hidden hides a field in the interface; readonly restricts editing an existing record. Neither replaces server permissions. --ui-component and --ui-width select a supported presentation, but do not insert arbitrary React code.

sortable, filterable and searchable correspond to List behavior. After Generate, supported server-side sorting, typed filters and search become available. The client uses sort/order, filters and searches according to the API contract. This does not introduce arbitrary new query parameters. Settings incompatible with the type are rejected.

Commands and parameters

Command Invocation
field admingen-cli field [command]
field add admingen-cli field add <entity-name> <field-name> [flags]
field delete admingen-cli field delete <entity-name> <field-name> [flags]
field update admingen-cli field update <entity-name> <field-name> [flags]

Global parameters are covered in CLI basics. Replace names in angle brackets with your own. Defaults belong to command help: update does not reset omitted properties.

Parameter Used by Default Meaning
--auto-generate VALUE field add, field update empty string PK generation: uuid or identity; check compatibility with the field type.
--default VALUE field add, field update empty string String representation of a default value. Does not guarantee automatic filling of every omitted API field.
--description VALUE field add, field update empty string An explanation of the field's purpose.
--enum VALUE field add, field update empty list Unique allowed values, for example draft,published; order is preserved.
--filterable field add, field update false Enable typed server filters for a supported field.
--hidden field add, field update false Hide the field in the generated interface; this is not an API security policy.
--image-settings VALUE field add, field update empty string Image/gallery settings JSON; null explicitly clears settings if the resulting model permits it.
--indexed field add, field update false Request an index for the field.
--nullable field add, field update false Allow null within the type/relationship rules.
--primary-key field add, field update false Make the field the entity's primary key.
--readonly field add, field update false Restrict changing an existing value in the generated form; Create has separate behavior.
--relation-foreign-key VALUE field add, field update empty string FK field for the field's inline relationship definition.
--relation-target VALUE field add, field update empty string Target entity name for a reference field.
--relation-type VALUE field add, field update empty string Type of the field's inline relationship definition.
--required field add, field update false Make the value required according to model and form rules.
--searchable field add, field update false Enable server search for a supported string/text field.
--sortable field add, field update false Enable server list sorting for a supported field.
--title VALUE field add, field update empty string A human-readable project or field title.
--type VALUE field add, field update empty string For a field, a supported data type; for a relation, belongsTo, hasMany or manyToMany.
--ui-component VALUE field add, field update empty string Supported field presentation. This parameter does not inject an arbitrary React component.
--ui-width VALUE field add, field update empty string A positive integer pixel count as a string, for example 240.
--unique field add, field update false Request unique values.
--new-name VALUE field update empty string A new name where the command supports it. A regular update does not rename a persisted field: use Rename.

Markdown and images

admingen-cli --path ./docs-demo field update Article body --ui-component markdown
admingen-cli --path ./docs-demo field update Article title --ui-width 320 --searchable --sortable --filterable
admingen-cli --path ./docs-demo field add Article cover --type image --nullable \
  --image-settings '{"profile":"cover","formats":["jpeg","png","webp"],"quality":85,"output":"auto","sizes":[{"name":"sm","width":320},{"name":"lg","width":1600}]}'

Markdown changes how text is displayed, not its SQL type. Supported string/text options include textarea/password/email/url; an empty component selects Default.

--image-settings accepts strict JSON: an unknown key causes an error. Gallery also supports maxCount. The avatar profile specifies a square and cover specifies16:9. A positive aspect overrides the proportions; profile: custom with aspect: 0 preserves the original proportions.

Do not confuse accepted input formats with output: output accepts auto/jpeg/png. Size creation and file processing are described in images.

Field translations

There is currently no dedicated CLI flag for Localized. Configure languages and translated fields in Entity settings → Languages, save the model, then use normal CLI generation if preferred. You do not need to create nameRu/nameEn fields manually. See Languages.

If the field has already been generated

After the first successful generation, the storage type is fixed. To transform data, create a new field and a custom migration. Title, Description and Presentation can change independently of the storage type.

Deleting a regular generated column requires field delete ... --confirm-data-loss. Protected identifiers cannot be replaced this way. See renaming and deletion.