Summary

Implement first-party Drush support in entity_labels as a separate Drupal.org issue from #3581212, because the current checked-out
branch is for multilingual CSV behavior only. The feature will add four explicit commands for exporting and importing entity and
field label CSV data, reusing the module’s existing exporter/importer services rather than duplicating CSV logic.

Key Changes

Drupal.org contribution workflow

  • Work from web/modules/sandbox/entity_labels, not the site root.
  • Create a new Drupal.org issue for Drush support with scope limited to CLI export/import.
  • Base the new issue branch from upstream 1.0.x, not from the current 3581212-language-support branch.
  • Keep the MR focused on Drush support, tests, and README updates only.

    Public interfaces / commands

  • Add a new Drush commands class at src/Commands/EntityLabelsCommands.php.

  • Add drush.services.yml with a drush.command service tag.
  • Expose these commands:
    • entity-labels:entity-export [--entity-type=TYPE]
    • entity-labels:field-export [--entity-type=TYPE] [--bundle=BUNDLE]
    • entity-labels:entity-import
    • entity-labels:field-import
  • Command behavior:

    • Export commands write CSV to stdout.
    • Import commands read the given file, pass its raw contents to the existing importer service, and print a concise result
      summary (updated, skipped, and any reported errors).
    • entity-export supports --entity-type only.
    • field-export supports both scope options because the current field exporter already supports entity type and bundle drill-
      down.
    • Invalid file paths or unreadable files fail fast with a Drush error.
    • Importer/exporter exceptions are surfaced as Drush command failures with readable messages.

    Implementation details

  • Inject and reuse existing services:

    • entity_labels.entity.exporter
    • entity_labels.field.exporter
    • entity_labels.entity.importer
    • entity_labels.field.importer
  • Keep CSV generation consistent with the web UI by calling existing export() methods and streaming rows through fputcsv().
  • Keep import behavior consistent with the web UI by reading file contents and calling existing import(string $csv) methods.
  • Do not change routes, forms, or browser export/import behavior.
  • Update README usage docs to include the four Drush commands and remove the current Drush TODO section.
  • Do not add new module dependencies or change composer.json unless implementation reveals a hard requirement.

    Test Plan

  • Add kernel coverage for the Drush commands layer, focused on behavior rather than re-testing exporter/importer internals.

  • Export tests:
    • entity-export prints the expected CSV header and rows.
    • entity-export --entity-type=node limits output correctly.
    • field-export prints the expected header and respects --entity-type / --bundle.
  • Import tests:
    • entity-import updates config through the existing importer and reports counts.
    • field-import updates field labels/descriptions and reports counts.
    • Missing or unreadable import file returns a command error.
    • Importer parse failures propagate as command errors.
  • Run targeted module tests after implementation, at minimum the new Drush tests plus a sanity pass of existing entity/field
    importer/exporter tests.

    Assumptions and Defaults

  • New Drupal.org issue, new issue fork, new MR.

  • Four explicit commands are preferred over a grouped export/import command.
  • entity-labels:entity-export will not support --bundle.
  • Export output is plain CSV to stdout; no file-writing option is planned for v1.
  • Import commands are non-interactive and use a required file path argument.
  • No API/schema/config changes are intended beyond adding Drush command support.
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

jrockowitz created an issue. See original summary.

jrockowitz’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • jrockowitz committed 6ba8dfd0 on 1.0.x
    Issue #3581278: Add Drush support commands and tests
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.