Problem/Motivation
The default-content:export (dce) Drush command currently supports two output
modes: writing YAML to stdout (default) or writing to a specific file via --file.
However, the related default-content:export-references (dcer) command already
supports a --folder option that organises exported entities into subdirectories by
entity type, naming each file by UUID (e.g. {folder}/{entity_type_id}/{uuid}.yml).
This inconsistency means that when exporting a single entity with dce, there is no
convenient way to write the output directly into a content directory in the standard
layout used by the module. Users must either pipe stdout or manually construct the file
path, making dce harder to use in scripted workflows and inconsistent with dcer.
Steps to reproduce
- Install the
default_contentmodule. - Run
drush default-content:export node 1 --folder=modules/mymodule/content - Observe that the
--folderoption is not recognised by thedcecommand.
Proposed resolution
Add a --folder option to default-content:export (dce) that mirrors the behaviour
of dcer: the exported entity is written to {folder}/{entity_type_id}/{uuid}.yml,
consistent with the directory layout the module uses for imported content.
--fileand--folderare mutually exclusive; using both raises anInvalidArgumentException.- If neither option is given, output continues to go to stdout (existing behaviour preserved).
- A kernel test (
DefaultContentCommandsTest) is added covering all three scenarios:
--folderwrites the correct file,--file+--folderthrows, and stdout output is correct.
Remaining tasks
- Review and merge.
User interface changes
The dce / default-content:export Drush command gains a new --folder option. No UI changes.
API changes
None. The $options array of DefaultContentCommands::contentExport() gains a new optional
folder key, which is backwards-compatible.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3590646-dce-folder-option.patch | 5.73 KB | renaudcuny |
Issue fork default_content-3590646
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
renaudcuny commentedMR submitted, patch attached.
Note: I know there are other issues discussing the default behaviour of dce - I am not entering the debate or disregarding any arguments already made :), but simply providing --folder as an option here.