Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

fox

Security covered
View on drupal.org

The module adds drush command: fox:console (fox). Command allow you to obtain data at entity (context) levels. Context: entity_type.bundle .

The module can be useful during audits, migrations, developing, CI/CD and architecture reviews. May also be useful for CLI tools such as Pantheon hosting's terminus.

Console is a looped interactive command (like mysql console or FoxPro command window). The module keeps command history (by arrows up/down) and autocomplete (by tab).

Fox console has condition approach:
IF condition THEN fox commands ELSE fox commands.

The module uses variables that can be retrieved from the Fox Entity Query or using the SET command. A variable can be evaluated using the '@' symbol. Object field can be evaluated using the '.' symbol, e.g. @data.0.title.

A custom fox command can be easy added (example module is included).
Generating fox commands can be made by drush gen fox:command.

Usage examples:

    • # Block user with uid = 1
    • SELECT status FROM user WHERE uid = 1 INTO data
    • IF @data.0.status = 1 THEN REPLACE status WITH 0
    • # Create taxonomy vocabulary and taxonomy term
    • USE taxonomy_vocabulary
    • SELECT vid WHERE vid = test
    • IF @count <> 0 THEN QUIT
    • APPEND vid WITH test, name WITH Test, description WITH Test taxonomy, status WITH 1, weight WITH 0
    • USE taxonomy_term.test
    • APPEND name WITH test tags, description WITH Test tag, status WITH 1, weight WITH 0
    • PRINT Terms were created (count = @count)
    • # Delete orphaned nodes
    • SQL UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH)) AS last_month INTO data
    • PRINT Month ago timestamp: @data.0.last_month
    • SELECT nid FROM node WHERE status = 0 AND changed < @data.0.last_month INTO nodes
    • DELETE LOOP @nodes
    • # Replace a field by another field
    • USE node.page
    • SELECT nid,title INTO data
    • IF @count = 0 THEN QUIT
    • REPLACE field_title2 WITH @data.@__index.title LOOP @data

... more examples available in the README.md file

Parameters:

  • --input
    Input commands: "command1;command2" or load file
  • --output
    Output command history to screen or to file
  • --mode
    Command mode: [default]|debug
  • --quit
    Non-interactive mode

Entity query:

  • SELECT fields FROM context WHERE conditions ORDER BY order LIMIT limit OFFSET offset INTO variable
  • SET active TO 1; FROM user WHERE status = @active

Fox commands:

Navigation

  • USE
    Select context, for example node.page (node entity type, page bundle).
    Usage: USE [context]. USE without context cleared existing context.
  • GO
    Set context record.
    Usage: GO {TOP|BOTTOM|PREV [number]|NEXT [number]|number}
  • SEEK
    Seek context record by entity ID.
    Usage: SEEK id
  • BROWSE
    Browse fields for context record.
    Usage: BROWSE [*|fields] --vertical, --json").

Mutations

  • CREATE
    Create record.
    Usage: CREATE id, label
  • APPEND
    Append record with fields.
    Usage: APPEND [uField1 WITH eExpr1 [, uField2 WITH eExpr2]
  • CLONE
    Clone context record.
    Usage: CLONE [id, label]
  • REPLACE
    Replace fields for context record. Supports inner index variable @__index for LOOP option.
    Usage: REPLACE uField1 WITH eExpr1 [, uField2 WITH eExpr2] [LOOP @variable]
  • DELETE
    Delete context record.
    Usage: DELETE [LOOP @variable]

Variables

  • SET
    Set variables.
    Usage: SET var1 TO eExpr1 [, var2 TO eExpr2].
    Delete variable: SET var1 TO
  • PRINT
    Print variable.
    Usage:PRINT @var
  • TEST
    Test variables.
    Usage: TEST function variable operand value [message].
    Functions: COUNT.

Loading

  • LOAD
    Load file with fox commands.
    Usage: LOAD file
  • DRUSH
    Call an external Drush command.
    Usage: DRUSH command [JSON args] [JSON options])

Information

  • INFO
    List entities,bundles or fields list for entity,bundle.
    Usage: INFO [entity_id.[bundle]]
  • LIST
    List Fox commands.
    Usage: LIST
  • SQL
    Execute SELECT SQL.
    Usage: SQL expressions [INTO variable]
  • FILE
    Get file information.
    Usage: FILE uri [INTO variable]

Similar projects:

Sponsorship

...have a feature you'd like to sponsor? Get in touch

Activity

Total releases
24
First release
Feb 2025
Latest release
2 days ago
Release cadence
19 days
Stability
96% stable

Release Timeline

Releases

Version Type Release date
1.5.3 Stable Apr 16, 2026
1.5.2 Stable Apr 3, 2026
1.5.1 Stable Apr 1, 2026
1.5.0 Stable Mar 29, 2026
1.4.11 Stable Mar 26, 2026
1.4.10 Stable Mar 22, 2026
1.4.9 Stable Mar 14, 2026
1.4.8 Stable Oct 4, 2025
1.4.7 Stable Sep 21, 2025
1.0.x-dev Dev Sep 11, 2025
1.4.6 Stable Sep 11, 2025
1.4.5 Stable Jul 29, 2025
1.4.4 Stable Jul 23, 2025
1.4.3 Stable May 3, 2025
1.4.2 Stable Apr 29, 2025
1.4.1 Stable Apr 24, 2025
1.4.0 Stable Apr 24, 2025
1.3.6 Stable Apr 19, 2025
1.3.5 Stable Apr 13, 2025
1.3.4 Stable Apr 3, 2025
1.3.3 Stable Mar 23, 2025
1.3.2 Stable Feb 16, 2025
1.3.1 Stable Feb 13, 2025
1.3.0 Stable Feb 3, 2025