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

  1. Install the default_content module.
  2. Run drush default-content:export node 1 --folder=modules/mymodule/content
  3. Observe that the --folder option is not recognised by the dce command.

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.

  • --file and --folder are mutually exclusive; using both raises an InvalidArgumentException.
  • If neither option is given, output continues to go to stdout (existing behaviour preserved).
  • A kernel test (DefaultContentCommandsTest) is added covering all three scenarios:
    --folder writes the correct file, --file + --folder throws, 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.

CommentFileSizeAuthor
#3 3590646-dce-folder-option.patch5.73 KBrenaudcuny
Command icon 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

renaudcuny created an issue. See original summary.

renaudcuny’s picture

StatusFileSize
new5.73 KB

MR 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.