Grouping sites

Version check: the grouping features described on this page are available in WordShell 1.3.10 onwards.

In the last chapter we saw the form of a basic WordShell command:

wordshell [,[,...]]

Rather than entering a list of sites every time, you can define “groups” of sites within WordShell. To define a basic group, in the following example with the name  “mygroup” and members site1, site 2 and site3, use the switch –definegroup with the following syntax:

wordshell --definegroup=mygroup:site1,site2,site3

You can test what you did with –listgroups:

wordshell --listgroups
mygroup: site1,site2,site3

Henceforth, you can indicate the group you have created by prefixing it with a @ in the site list, i.e. @mygroup. e.g. to perform the –listsites action on that whole group:

wordshell @mygroup --listsites
site1     Enabled sftp:[email protected] /htdocs | http://example.com
site2     Enabled file:///home/myuser/site2 | http://localhost/s2
site3     Enabled file:///home/myuser/site3 | http://localhost/s3

More advanced usage

In fact, the list of sites that you supply to WordShell can be not just a list of sites, or a group, but any combination of them, and can also have exclusions. Exclusions are indicated by prefixing with a minus sign. For example:

# All the members of two groups:
wordshell @mygroup,@mygroup2

# Include the members of two groups, plus site2, but make sure that site3 was not included:
wordshell @mygroup,@mygroup2,site2,-site3

# Include all members of mygroup, and then exclude all members of mygroup2:
wordshell @mygroup,[email protected]

This can also be done when defining a group:

# Define group "mynewgroup"
wordshell --definegroup=mynewgroup:@mygroup,[email protected] ,site2,-site3

The only thing to remember is that WordShell evaluates all lists fully at the point when they are specified. Therefore, if you define a group as above, in terms of other groups, then those groups are enumerated out into a list of sites at that point. In the above example, if you change the members of the group @mygroup later on, then the group @mynewgroup will not be affected until you re-run the –definegroup command to define it afresh.

Taking all the above into account, therefore the way to add a site to a group (or ensure that it is already present) is as follows:

wordshell --definegroup=mygroup:@mygroup,mysite

And the way to remove it (or ensure that it is not present) is like so:

wordshell --definegroup=mygroup:@mygroup,-mysite

Groups can be deleted with –deletegroup (or –delgroup for shortness):

wordshell --delgroup=mygroup

Now that we know how to add sites and groups of sites to WordShell, it is time to move on to some actual WordPress operations in the next chapter.

Next chapter:  Working with plugins
Previous section: A basic WordShell command
Chapter index: Starting to use WordShell
In fact, the list of sites that you supply to WordShell can be not just a list of sites, or a group, but any combination of them, and can also have exclusions. Exclusions are indicated by prefixing with a minus sign. For example:

Leave a Reply

Site Map