views-list (or views-status maybe?) would dump out a simple ASCII table of all the views on your site, the code/db/revert status, if they're enabled/disabled, etc. Exact formatting and fields TBD, but something to quickly see the status of all your views without views_ui would be cool.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 1096650-drush-views-list-rerolled-dt-32.patch | 6.75 KB | DjebbZ |
| #22 | drush-views-list-1096650-22.patch | 6.88 KB | DjebbZ |
| #19 | drush-views-list-1096650-5.patch | 6.17 KB | DjebbZ |
| #13 | drush-views-list-1096650-5.patch | 4.49 KB | DjebbZ |
| #12 | drush-views-list-1096650-4.patch | 4.49 KB | manuel garcia |
Comments
Comment #1
manuel garcia commentedComment #2
manuel garcia commentedHere is a first go at it:
drush views-listor:
drush vlComment #3
DjebbZ commentedThe patch looks good. A very useful command.
Can you add an entry in the hook_drush_help() ?
Comment #4
manuel garcia commentedOK, here's some progress,
drush help views-listWe now also list the tags of each view in the table.
There's now a new option available when you call the command:
drush vl --tags=tag1,tag2I've also renamed the function to the default taken by drush, following best practices.
Comment #5
DjebbZ commentedGreat ! I corrected small typos, and proposed small improvements to output. What do you think ?
And hey : I don't know how to roll patches with Git... Looks like my patch is against your previous patch, uh ?
Comment #6
DjebbZ commentedAnd a question : how do you debug code that prints in the command line ? You cannot use dsm or a debugger like xdebug I suppose... Do you 'drush print' stuff ?
Comment #7
jwilson3Awesome addition!
Some documentation feedback:
1) Don't end the sentence with "by", Core also uses comma-separated.
becomes:
2) Consider standardizing on using the word "Display" or "Show" in place of "Prints out" and "get". (`drush pm-list` uses "show").
3) 'the system' is not used elsewhere in other drush command documentation, and is probably not necessary.
becomes:
and
becomes
Functional review to come....
Comment #8
jwilson3One more nitpick, a classic dilema in English: on versus in.
I think in this case, "in" sounds and reads better.
Comment #9
jwilson3I have 112 views on a production site of mine, and this list would be hugely more helpful if it were sorted by view name alphabetically by default, just as the Views UI does.
I tried to modify the line where views_get_all_views() is called, to add a ksort, but it consistently showed zero views :-/ my php fu is weak today.
Comment #10
jwilson3Actually, Views UI seems to sort first by status (enabled at the top, disabled at the bottom) and THEN by view name.
Comment #11
manuel garcia commented@DjebbZ you can use the drush function
drush_print_r($mystuff);@jrguitar21 many thanks for the reviews, they all make sense. I'll get to them soon.
Comment #12
manuel garcia commentedOK, here is some more progress.
I've worked on what you did DjebbZ, which made sense. I've made the changes to the text strings you mentioned jrguitar21, and the table is now built like this: First we sort the enabled and disabled views separately, and then we put the enabled first and then the disabled views.
The result is a list with the enabled on top, each group sorted alphabetically.
I've also made some changes to the code structure so it makes a bit more sense and it's easier to read.
Comment #13
DjebbZ commentedWe're getting closer to a perfect command here :)
One suggestion : should we put the "Tag" column just after the name column, like Views UI ? Because a tag is an identifier too, it should be close to the real identifier. Other columns are info.
In the patch, added 2 options :
drush vl --status=enabled|disabled
drush vl --type=normal|default|overridden
Second is a bit broken, I'm tired it's a bit late... And I reworked output with a not-proper-yet-because-it's-late summary of all options used, the same kind I added before with "Views tagged [tag]". And I didn't move the "Tag" column.
This code is WIP, far from clean. Especially I wanted to use ternary conditions to test validity of user input, but I wasn't able at this time of the night... Maybe we can validate user input only if he writes proper things in options ?
Comment #14
DjebbZ commentedNeeds work and review actually.
Comment #15
jonhattan@DjebbZ patch in #13 seems the same in #12. It does not implement --status and --type
Comment #16
manuel garcia commented@DjebbZ the patch 5 is exactly like my last one, I think you didn't commit your changes to git before doing the diff...
Comment #17
DjebbZ commentedAh sorry guys it was late... I'll post it tonight when I go back home.
A git-related question : I created a local branch for this issue. If I apply patches/make changes in this branch, how to diff against the 1st commit of the branch, so the patch includes all changes ?
Comment #18
dawehnerto find your commit ID.
After this you can use
to get a diff again the right version.
Comment #19
DjebbZ commentedIt should be the good patch. Didn't change since yesterday.
Thank you dereine for your tip :)
Comment #20
dawehnerIt seems to be that this calls misses dt(). Not sure whether it should be applied or not
Comment #21
DjebbZ commentedI think it should, I found calls with dt() in the devel module.
Comment #22
DjebbZ commentedBetter yet : --tags, --type and --status work, and I added a --name option. Basically you restrict the results to all views containing your string. It prints a nice summary of options used before the list itself.
I hope we're good.
Comment #23
DjebbZ commentedbojanz told me that Drush commands should exist in their own module. I don't know if it's necessary because drush may discover by itself the /drush/views.drush.inc file, so that it doesn't impact the main module. It needs to be verified.
And all Drush commands may need more documentation, maybe appear in their own "fieldset" when you type
drushin the prompt (There are "Core drush commands", "User commands", "Fields commands"). And even have their own drush-topic.Comment #24
dawehnerbojanz told me that Drush commands should exist in their own moduleWell should is not have to. Is there a specific reason for it? It definitive works already in the drush/views.drush.inc file.
Comment #25
dawehnerI'm a bit confused about
For the other drush issue there were no call to dt() so i looked it up in sql.drush.inc and there were none.
Can someone clarify whether there should be some or not? drush/examples/sandwich.drush.inc doesn't use this there.
Comment #26
jwilson3dtis simply a drush wrapper for Drupal'st. So if there is text, that is translatable... I don't see why not to use it.Perhaps the use of
dtis sparse because internationalization of Drush hasn't been a big priority as it's never seen by end users?Comment #27
jonhattanThe standard is to not use dt() in commands description or examples although drush itself uses it in some commands. Also, I think localizing drush is not neccesarry. I've open an issue to discuss that in drush's queue #1159146: Clarify usage of dt() in hook_command().
Comment #28
DjebbZ commentedAs Moshe Weitzman said in the thread you created, in comment #7,
So we should keep it, and even go and update drush core itself to include
dt()in command descriptions.Comment #29
DjebbZ commentedWell, the conversation is going on in the aforementioned issue, looks like we should wait before deciding whether to use dt() or not in command descriptions. It is completely valid and recommended today, but maybe not in future versions of Drush.
Comment #30
jonhattanFinally: no need to use dt() in command description, arguments, options, examples.... drush will pass strings through dt() in its internals, similar of what drupal does with items defined in hook_menu().
Comment #31
dawehnerThanks for the clarification.
Commited the changes mentioned in #30 for the already existing commandos.
Then i wanted to continue to try out this patch but sadly this patch does not apply anymore.
Comment #32
DjebbZ commentedI rerolled my patch #22 and removed dt() calls in hook_drush_command. Is it the only place that needs changes ?
(git is wonderful, so easy to grab the last changes...)
Comment #33
dawehnerThanks for rerolling!
Commited to 7.x-3.x and 6.x-3.x. Drush integration get's better and better
Comment #35
manuel garcia commentedAwesome! Thanks everyone for the work on this, sorry I haven't worked on it at the end... not much time lately, you know how it is...
on a side note, dereine, my name is Manuel... not Manual hahah (in commit messages) lol
Comment #36
dawehnerOh sorry, i'm so sorry. Next time i will c&p names again. How embarrassing
Comment #37
DjebbZ commentedHappy for this contribution to Views :)
Comment #39
DjebbZ commentedI noticed a problem with the command. Whenever I use it with an drush site alias when I'm outside a drupal directory, it tries to list views named [alias]. See :
How come ?
Comment #40
manuel garcia commentedw0a there's an interesting bug, I'll try dig into it soon... I'm wondering whether we should create a bug report for this though
Comment #41
merlinofchaos commentedYes, please create a separate issue report.
Comment #42
DjebbZ commented#1220500: Drush views-list command doesn't work with site alias