Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2009 at 00:34 UTC
Updated:
29 Nov 2009 at 21:14 UTC
Jump to comment: Most recent file
The script command could use a --script_path option that lets you define additional search paths for files.
I created a small patch that adds a --script_path option for the script command. You can define this option in drushrc.php.
// Specify additional directories to search for scripts
// Use POSIX path separator (':')
# $options['script_path'] = 'sites/all/scripts:profiles/myprofile/scripts';
I find this useful for building a customized library of drush scripts. Additionally, it removes the overhead of creating new commands for trivial pieces of functionality.
I have used this successfully on 5.x and 6.x sites.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | core.scriptlist.patch | 747 bytes | brad.bulger |
| #2 | drush_script_path_591628_2.patch | 2.01 KB | srhaber |
| drush_script_path.patch | 2.08 KB | srhaber |
Comments
Comment #1
moshe weitzman commentedSorry for my delay. Alas, does not apply cleanly anymore. Care to reroll?
Lets add an 'examples' item to the script command which illustrates how to use this.
Comment #2
srhaber commentedApologies, that initial patch was created against 6.x-2.0.
Here's an updated patch created against the HEAD. It includes an 'examples' item.
Comment #3
moshe weitzman commentedWould be nifty if this command could list available scripts if no argument is provided. I guess we would mistakenly show some scripts in cwd() under soem use cases but i guess thats ok. Thoughts?
Comment #4
srhaber commentedI like that idea. We could group the results under their respective directories so the cwd() listing wouldn't cause too much clutter. I suspect we'd only care to display *.php files?
Even cooler would be to make this work with autocomplete magic #437568: Autocomplete awesomeness for drush.
Comment #5
moshe weitzman commentedyes, just .php extension
we should probably recurse down the specified search paths. but doing that on drush_cwd() would often give too many results so lets skip it there. drush has a directory walk function that seems appropriate for this.
Comment #6
moshe weitzman commentedOne more idea. I have started using a scratch.php script where I just put a few lines of php that I want executed after a full bootstrap. It is a handy deb tool. I wonder if we should put a scratch.php in the distro and put it where it will be found by a script listing.
Comment #7
moshe weitzman commentedCommitted this patch with the improvements that I described.
Comment #9
brad.bulger commentedthe script listing needs to use array_merge() instead of the '+' operator to add the scripts found in each directory in the path. '+' won't add new entries with keys matching existing keys, numeric keys included.
Comment #10
moshe weitzman commentedcommitted thanks.