yamlexchange import
Imports the contents of a YAML file into the Next Design model and saves the project.
The matching and updating rules are the same as for [Import] on the screen. See Import Rules for details.
By default, items not written in the YAML are not changed (same as [No] on the screen). Specifying --complete and --prune together will remove unwritten references and delete unwritten child elements (same as [Yes] on the screen).
Returns (0) if the import was successful, (1) if it was successful with warnings, and (2) if it failed.
Also displays a message in the console notifying you of the command execution result.
- Close the same project in Next Design before running the import. Do not perform simultaneous imports to the same project. yamlexchange will overwrite the project without warning, without checking if the project is open in Next Design.
- Imports made with yamlexchange are irreversible. To revert to the state before the import, restore the entire project file set using Git or similar.
- If you imported with
--write-back, restore the YAML file as well (or delete the rewrittenidline or change it back to a value starting withnew-). Restoring only the project will remove the model with the rewrittenid, causing the next import to fail with an error.
Syntax
yamlexchange import --project <nproj> --in <yaml>
[--parent <id or path>]
[--field <owning field name>]
[--dry-run]
[--complete]
[--prune]
[--write-back]
[--report <path>]
Options
-
--project <nproj>(required)
Specifies the Next Design project file (.nproj). -
--in <yaml>(required)
Specifies the YAML file to import. For split YAML files, specify the main file. -
--parent <id or path>
Specifies the model to import into. This command searches for this model within the--inYAML file and imports only that model and its sub-models if found. If not found, it searches the entire file under this model and imports it.
This is used when importing only a portion of a split YAML file or when specifying the destination for a new model written at the outermost edge of a file. It can be omitted if the file only contains models that can be matched by id. See How to write commands for details.
-
--field <owning field name>
This specifies which owning field of the--parentmodel to add a new model written at the outermost edge of the file (without specifying a parent) to. (Required if there are multiple candidates.) -
--dry-run
This displays the number of changes and details without applying the import. The project is not saved. -
--complete
This imports anything not written in the file, treating it as "non-existent". References that are not written will be removed (references written in the field at the opposite end of the relationship will remain). (When combined with--prune, it will also remove child elements that are not written, including the entire line of the field name.)
See Handling of Unwritten Items for details.
--prune
Deletes child elements that are not written in the YAML. (Specify this in combination with--dry-runand apply it after confirming the deletion schedule.)
When combined with --complete, it will also delete child elements that are not written, including the entire line of the field name.
See Delete for details.
-
--write-back
Writes theid(short ID) of the newly created model back to the imported YAML file. Importing the same file again will prevent duplicate models from being created. -
--report <path>
This command writes the execution results to a JSON file. See Execution Report for details.
Deletion
Model deletion during import is only possible when --prune is specified.
When --prune is specified, it deletes child elements that have been removed from the YAML among the child elements of the model written in the YAML.
If the field name line that lists the child elements (e.g., SubGroups:) is not written, that child element will not be deleted.
Elements outside the scope written in the YAML (such as siblings or ancestors of the written model) will not be deleted.
Models moved to a different location in the YAML are treated as moved and will not be deleted.
- Specifying both
--completeand--prunetogether will delete child elements that are not written with a field name line. - When importing with
--prune, deleting theidline of an existing model will create a new model, and the original model will be deleted. References to that model from other models will also be lost. - First, run with
--dry-runto confirm which models will be deleted.
The deletion procedure is as follows:
- Delete the model you want to delete from the YAML.
- Run with
--pruneand--dry-runto confirm the list of models to be deleted. - Import with
--prune.
If you delete the $file line that points to the split destination and add --prune, the model in that split destination will be deleted along with its subdirectories (the line for a file containing only a table of contents is an exception and will not be deleted even if deleted).