Drush entity support (patch needs review)
Submitted by clemens on Mon, 2011/11/07 - 9:44am
Can you tell the field display weights of all your entities with one command? Or edit a node through the command-line?
drush --yaml entity-type-read node --fields=**/display/**/weight --include-fieldapi
drush entity-update node 12 --json
Watch the video on http://www.youtube.com/watch?v=cVGZzWjdDh8 and get convinced you want to know more of these entity internals.
The patch is http://drupal.org/node/1005480 and I think it is a nice way to query Drupal for how your own entity settles in. At least I used entity-type-read when developing my entities.
Below are all commands done in the video to test yourself. Or read the patch from helmo's sandbox
Comments about how to make a better video are welcome here.
For patch reviews ... well you know where to go :p
=================================
Drush Entity support ... patch #1005480
---------------------------------
Visit http://drupal.org/node/1005480
=================================
What entities are there installed.
---------------------------------
drush entity-type-read
---------------------------------
=================================
How does user look
---------------------------------
drush entity-type-read user
---------------------------------
=================================
Shorter output ... --yaml
---------------------------------
drush --yaml entity-type-read user
---------------------------------
=================================
Unreadable short ... --json
---------------------------------
drush --json entity-type-read user
---------------------------------
=================================
Can I filter types ... --fields
---------------------------------
drush --yaml entity-type-read node --fields=label
---------------------------------
=================================
Can I query multiple entity types? ... sure
---------------------------------
drush --yaml entity-type-read user node --fields=label,bundles/*/label
---------------------------------
=================================
But I want all labels ... --fields=**/label
---------------------------------
drush --yaml entity-type-read user node --fields=**/label
---------------------------------
=================================
But what about the fields entites? ... --include-fieldapi
---------------------------------
drush --yaml entity-type-read node --fields=**/label --include-fieldapi
---------------------------------
=================================
What are the weights of the node displays ... **/display/**/weight
---------------------------------
drush --yaml entity-type-read node --fields=**/display/**/weight --include-fieldapi
---------------------------------
=================================
Give me all display weight (comment and node)
---------------------------------
drush --yaml entity-type-read `drush entity-type-read` --fields=**/display/**/weight --include-fieldapi
=================================
json please ... --json
---------------------------------
drush --json entity-type-read node --fields=**/display/**/weight --include-fieldapi
---------------------------------
=================================
What controller classes do we have?
---------------------------------
drush --yaml entity-type-read `drush entity-type-read` --fields="controller class"
---------------------------------
=================================
Are there nodes? ... entity-read
---------------------------------
drush entity-read node
---------------------------------
=================================
Generate some please ... devel.module
---------------------------------
drush --yes en devel_generate
---------------------------------
drush genc 10 4
---------------------------------
=================================
Show me your nids ... entity-read
---------------------------------
drush entity-read node
---------------------------------
=================================
What are the comment statistics?
---------------------------------
drush entity-read node 2 5 10 --fields=title,comment_count --yaml
---------------------------------
=================================
How about user 1
---------------------------------
drush entity-read user 1
---------------------------------
=================================
Comments ... please fix body index=0 bug
---------------------------------
drush --yaml entity-read comment 1 2 --fields=subject,**/body_format/**/format
---------------------------------
=================================
Now create some terms please ...
---------------------------------
drush gent tags 10
---------------------------------
=================================
TIDs please ...
---------------------------------
drush entity-read taxonomy_term
---------------------------------
=================================
List term 2
---------------------------------
drush entity-read taxonomy_term 2 --fields=name,description --yaml
---------------------------------
=================================
Update term 2
---------------------------------
drush entity-update taxonomy_term 2
---------------------------------
=================================
List term to proof edit
---------------------------------
drush entity-read taxonomy_term 2 --fields=name,description --yaml
---------------------------------
=================================
Delete term 2
---------------------------------
drush entity-delete taxonomy_term 2
---------------------------------
=================================
List term IDs
---------------------------------
drush entity-read taxonomy_term
---------------------------------
=================================
Delete multiple terms
---------------------------------
drush entity-delete taxonomy_term 2 3 4 5
---------------------------------
=================================
List remnants
---------------------------------
drush --yaml entity-read taxonomy_term `drush entity-read taxonomy_term` --fields=name,description
=================================
Please test patch #1005480
---------------------------------
=================================
Code by helmo, clemens.tolboom, msonnabaum
---------------------------------
=================================
Video by clemens.tolboom
---------------------------------
=================================
Tools: screenflow, bash
---------------------------------
=================================
._-= The End =-_.
---------------------------------
Visit http://drupal.org/node/1005480