wireshell - an extendable ProcessWire command line interface

Recommended Posts

wireshell 1.0.0 is out

Quote

wireshell 1.0.0

Compatibility: ProcessWire 3.x

• Prepares wireshell for ProcessWire 3.x, adds namespace support, only supports ProcessWire 3.x
• Improves module:upgrade command, if no argument is provided it just checks for upgrades
• Extends new command, adds option --src=path/to/source to be able to use a pre-downloaded tgz/zip/folder
• Extends status command, only shows database password if --pass option is provided, shows if an upgrade is available
• Updates upgrade command, removes options dev and devns

-------- Original post -----------

Now this one could be a rather long post about only an experimental niche tool, but maybe a helpful one for some, so stay with me

Intention
Do you guys know "Artisan" (Laravel) or "Drush" (Drupal)? If not: These are command line companions for said systems, and very useful for running certain (e.g. maintenance, installation) task quickly - without having to use the Admin Interface, first and foremost when dealing with local ProcessWire installations. And since it has a powerful API and an easy way of being bootstrapped into CLIs like this, I think such a tool has a certain potential in the PW universe.

It's totally not the first approach of this kind. But: this one should be easily extendable - and is based on PHP (specifically: the Console component of the Symfony Framework). Every command is tidily wrapped in its own class, dependencies are clearly visible, and so on.

( Here was the outdated documentation. Please visit wireshell.pw for the current one )
• 33

Share on other sites

Just as I'm in the means to build a separate directory for bugfixes, where I just paste in disposable processwire installations. Really great. Will certainly take a look at it later. I can also see this very useful for setting up base installations in a more flexible way than siteprofiles.

• 2

Share on other sites

Sure I will help with what I can .

Thank you.

• 4

Share on other sites

Great! Thanks for this, Marcus. So far, everything looks good here on Windows - have only just installed PW-dev, going to work with other commands now. (Update: Everything works like a charm. Looking forward to seeing more Commands.)

For Windows users interested in making this global:

1. Make sure PHP is in your PATH
2. Create a wireshell folder somewhere (also added to your path), and create a wireshell.bat file:
@echo off
php "path\to\wireshell" %*


Then you can run wireshell new --dev anywhere you like.

• 6

Share on other sites

Thanks for the positive feedback!

• Attach roles on the fly while user creation: $wireshell create-user foo --roles=superuser,editor • Create templates and attach existing fields on the fly with$ wireshell create-template contact --fields=body,sidebar , prevent template file creation with --nofile
• Command aliases now available: c-u, c-t, c-r, s

Now planning field creation.

• 6

Share on other sites

Ever since I learned about drush I knew PW could benefit greatly from similar tool. Great job, Marcus!

Those "with dashes in-between" comands look a little weird for a cli interface. I saw you can easilly add aliases for commands, so maybe cr showd be included as a third one (as it is quicker to type)? Drush commands comprise of an object being manipulated followed by a "manipulation type". Not saying it is the right way to go, but it is better to choose some naming pattern explicitly.

Wireshell is a bit long too... Why not add an alias like ''wish" (for WIre SHell). It sounds magical, and isn't PW a wish come true?!

Thank you for developing this!

P.S. It kind of bugs me a little that this cli tool is written with symphony, not with PW itself. I am not even close to being able to argue here, but can it even be done?

• 1

Share on other sites

Ever since I learned about drush I knew PW could benefit greatly from similar tool. Great job, Marcus!

Those "with dashes in-between" comands look a little weird for a cli interface. I saw you can easilly add aliases for commands, so maybe cr showd be included as a third one (as it is quicker to type)? Drush commands comprise of an object being manipulated followed by a "manipulation type". Not saying it is the right way to go, but it is better to choose some naming pattern explicitly.

Wireshell is a bit long too... Why not add an alias like ''wish" (for WIre SHell). It sounds magical, and isn't PW a wish come true?!

Thank you for developing this!

P.S. It kind of bugs me a little that this cli tool is written with symphony, not with PW itself. I am not even close to being able to argue here, but can it even be done?

Regarding aliases: Yeah, I'm aware of the dash, and wanted to try cr, cu, ct first, but in the case of "cr" Symfony Console bugged me with the following error:

So in favor of consistency (cu. ct. cro?) I went for the dash.

• 14

Share on other sites

Great! Thanks for this, Marcus. So far, everything looks good here on Windows - have only just installed PW-dev, going to work with other commands now. (Update: Everything works like a charm. Looking forward to seeing more Commands.)

For Windows users interested in making this global:

1. Make sure PHP is in your PATH
2. Create a wireshell folder somewhere (also added to your path), and create a wireshell.bat file:
@echo off
php "path\to\wireshell" %*


Then you can run wireshell new --dev anywhere you like.

Since Wireshell is on packagist now and "composer global require wireshell/wireshell" installs it into "~/.composer/vendor/bin/wireshell" on Linux, could you test/check what the comparable Windows path or workflow would be? I'm currently rewriting (simplifying) the installation guide. Cheers!

• 2

Share on other sites

On Windows, it installs to C:\Users\<user>\AppData\Roaming\Composer\vendor\wireshell\wireshell\ ... Not sure what the best way of making this global is, other than making a batch file look specifically in that directory. I must admit: I'm not a composer fundi, but I get the basics...

Update: In fact, if I run wireshell directly from the above directory (using php wireshell), it doesn't run because it's looking for vendor/autoload.php in that directory too. If I run the nasty php vendor/wireshell/wireshell/wireshell from the C:\Users\<user>\AppData\Roaming\Composer directory, it works. Phew, quite messy. But, like I said, I'm no fundi - there must be a better way to do this.

• 1

Share on other sites

On Windows, it installs to C:\Users\<user>\AppData\Roaming\Composer\vendor\wireshell\wireshell\ ... Not sure what the best way of making this global is, other than making a batch file look specifically in that directory. I must admit: I'm not a composer fundi, but I get the basics...

Update: In fact, if I run wireshell directly from the above directory (using php wireshell), it doesn't run because it's looking for vendor/autoload.php in that directory too. If I run the nasty php vendor/wireshell/wireshell/wireshell from the C:\Users\<user>\AppData\Roaming\Composer directory, it works. Phew, quite messy. But, like I said, I'm no fundi - there must be a better way to do this.

Thanks so far! I discovered an installation guide for "laravel install" on windows: http://www.bitspedia.com/2014/09/how-to-install-and-make-first-laravel.html :

1. Add your ~/.composer/vendor/bin path into Path environmental variable, so that Windows Command Prompt could identify laravel command that would be used later to install Laravel and doing other tasks. In my case the path where its located is: C:\Users\UserName\AppData\Roaming\Composer\vendor\bin

so I added it into my Path environmental variable. Must restart your Shell or Command-Prompt so that updated Path variables is loaded.

And when I googled "windows Path environmental variable", got this: http://www.computerhope.com/issues/ch000549.htm. This GUI/matrix seems to be the counterpart to .bashrc.

Create an account

Register a new account

• Similar Content

• Hi Guys,
I have been debugging a site for the last 2 hours and cannot solve the issue.
I have a site running on 3.0.148.
I installed the Kongondo Blog module and was updating the templates to include the website style.
Once everything was set and done, I checked the page tree to see an error appear.
Template must be assigned a name before 'filename' can be accessed
The same error appears in templates.
Debugging Steps
I checked the templates in the server to ensure I didnt accidentally delete the namespace.  Deleted cache in browser and server under assets Still no go.
Any help is appreciated.
Thanks!
• By Spyros
Hello
I'm having a strange issue with the $page->find(), for some reason I'm missing some of the pages from the results. I found then that I was missing all the pages with the same "PAGE NAME". Is it a bug or am I missing something? PS If I change the "PAGE NAME" of one of the missing ones then I'm retrieving the page without any problem. Thank you • This short script loops through some images from an XML feed and pushes new ones to an image field. It all works perfectly, except for some reason the last image (only) in the loop each time doesn't receive the image description... can everyone spot why? TIA! 🙂 foreach ($propertyImages as $img) {$fileName = trim($img[0]); if ( !empty($fileName) ) { $imgPath = '../property_data/'.$fileName; if(file_exists($imgPath) && !in_array(strtolower($fileName),$currentImages)) {$p->property_images->add($imgPath);$p->save(); $newImg =$p->property_images->last(); $newImg->description =$img[1]; $p->save(); } } } • Hello everyone! I am working with Processwire since some time. But some topics are quite hard for me. I have a Portfolio (Gallery) Page. I am build a template with Portfolio Index and pages with portfolio entries. Structure: Portfolio Index -- Portfolio Entry -- Portfolio Entry and so on. Portfolio Entry has an Image field with max 12 images and are accessible Templates. Now I want to display the single Portfolio Entry on the Portfolio Index and Paginate them. In the index page all images of a single Entry page should be displayed (I should not be organized as albums, where a random image of the portfolio entry should be displayed). I have no clue to achieve this. May someone could give me an advice. Thank you in advance! • By ngrmm I have a page with a table. Each table row has a page-reference field and a checkbox. The Page sends emails to all users (page-refrence->email-field) and change the value of the checkbox in a row to 1. It works with this: <?php // event ID fron url query$eventID = $input->get('eventID','int'); // get event-page$event = $pages->get($eventID); // config $fromEmail =$event->event_mail_from; $fromName =$event->event_mail_from_name; $emailSubject =$event->event_subject; // email html body ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // make event-page editable$event->of(false); // loop through table and send out emails foreach($event->event_clients_list as$event_table_row) { // get client page $clientPage =$event_table_row->client_name; // get client email $clientEmail =$clientPage->email; // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email$m = new WireMail(); $m->to($clientEmail); $m->from($fromEmail, $fromName);$m->subject($emailSubject);$m->bodyHTML($emailBody);$m->send(); // mark client as invited $event_table_row->client_invited = 1;$event->save('event_clients_list'); } } ?> But i have to use a variable in my emailbody.inc which i'm able to get in the table-loop.
So i do the including of the body inside my loop. But this doesn't work anymore. Page sends out the emails but is unable to change the value of the checkbox.
I get no errors!
I'm using ProTable
<?php // event ID fron url query $eventID =$input->get('eventID','int'); // get event-page $event =$pages->get($eventID); // config$fromEmail = $event->event_mail_from;$fromName = $event->event_mail_from_name;$emailSubject = $event->event_subject; // loop through table and send out emails foreach($event->event_clients_list as $event_table_row) { // get client page$clientPage = $event_table_row->client_name; // get client email$clientEmail = $clientPage->email; // email html body ob_start(); include('./_inc/emailbody.inc');$emailBody = ob_get_clean(); // make event-page editable $event->of(false); // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email $m = new WireMail();$m->to($clientEmail);$m->from($fromEmail,$fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); // mark client as invited$event_table_row->client_invited = 1; \$event->save('event_clients_list'); } } ?>
×
×
• Create New...