fox
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 and architecture reviews.
Console is a looped interactive command (like 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 = 1SELECT status FROM user WHERE uid = 1 INTO dataIF @data.0.status = 1 THEN REPLACE status WITH 0
-
# Create taxonomy vocabulary and taxonomy termUSE taxonomy_vocabularySELECT vid WHERE vid = testIF @count <> 0 THEN QUITAPPEND vid WITH test, name WITH Test, description WITH Test taxonomy, status WITH 1, weight WITH 0USE taxonomy_term.testAPPEND name WITH test tags, description WITH Test tag, status WITH 1, weight WITH 0PRINT Terms were created (count = @count)
-
# Delete orphaned nodesSQL UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH)) AS last_month INTO dataPRINT Month ago timestamp: @data.0.last_monthSELECT nid FROM node WHERE status = 0 AND changed < @data.0.last_month INTO nodesDELETE LOOP @nodes
... 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 variableSET 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 - REPLACE
Replace fields for context record.
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
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:
- Bill of Lading - generates a list of Drupal structures
Sponsorship
...have a feature you'd like to sponsor? Get in touch