Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created uuid command to generate new UUIDs. #21

Closed
wants to merge 1 commit into from

Conversation

pfrenssen
Copy link
Member

In Drupal 8 we will be dealing with UUIDs, see for example Add UUIDs to default configuration. Here is a simple drush command that will output a fresh UUID on the command line.

$ drush uuid
81779421-39c3-422e-8500-d1e7854ce8df

@weitzman
Copy link
Member

Thanks. Hmmm. This is part of Drupal core but I think this is pretty rarely used functionality. When do you imagine it being used? I think this fits better with devel's drush integration.

  1. You should return the output of uuid->generate() so it is available to backend calls.
  2. The file should be named uuid8.drush.inc so it only loads for Drupal 8 sites.
  3. I don't think there is any benefit to hooking up simple strings like this to the outputformat system but maybe @greg-1-anderson has a different vision. So drush_print() is probably fine here.

@greg-1-anderson
Copy link
Member

If the output is a simple string, then there is no need to format it with the outputformat system. However, I think it is still useful to return the string as the function result & let Drush print it, for consistency. As mentioned above, returning the output as the function result will also make it available to backend calls (or folks who may want to call your command function directly).

@pfrenssen
Copy link
Member Author

Thanks for the feedback! Integrating it with the Devel module instead of core Drush makes sense indeed, as this is mainly for developer use. I'll make an issue in the Devel issue queue.

I was also thinking of adding a "n" argument so you can request multiple UUIDs:

$ drush uuid -n 10

@weitzman
Copy link
Member

I don't think many unix commands offer a 'repeat n times' option. Probably best to do it in a loop outside of drush

@weitzman weitzman closed this Aug 21, 2013
@weitzman
Copy link
Member

@greg-1-anderson - Returning a string from a command callback will now automatically get it printed. I just tested this. Perhaps we have a bug.

@pfrenssen
Copy link
Member Author

Here's the issue I opened for the Devel module: Provide a drush command to generate UUIDs.

I've reworked the patch a bit and am returning the value now as well as printing it. BTW for me the string is not printed automatically when returned, I have to explicitly print it.

Thanks for the feedback and suggestions!

@greg-1-anderson
Copy link
Member

The outputformat code didn't actually work as I describe above. I submitted a pull request that brings the code into alignment with my expectations; see: #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants