# wireshell - an extendable ProcessWire command line interface

## Recommended Posts

marcus    537

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 )
• 32

##### Share on other sites
LostKobrakai    4,310

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
Hari KT    83

Sure I will help with what I can .

Thank you.

• 4

##### Share on other sites
Mike Rockett    967

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
marcus    537

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
Ivan Gretsky    804

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
marcus    537

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
marcus    537

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
Mike Rockett    967

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
marcus    537

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

• ### Recently Browsing   0 members

function updateScore($player,$task, $real = true) { [...]$player->score = $player->score+$task->score; if ($task->name == 'new-equipment') {$new-eq = $pages->get("name=sword");$player->equipment->add($new-eq); } if ($real == true) {   $player->save(); } } Everything works fine when I call updateScore($player, $task, true), but if I call updateScore($player, $task, false), scores are untouched, but the equipment gets added ! It used to work fine on PW2.7 but my update to PW 3.0.62 seems to have broken this... Is there a simple explanation ? I keep reading my code over and over and this is driving me crazy... Thanks ! • By zaib I've a page "blog" which have child pages (blog posts). Right now I've 11 pages (blog posts) and I'm fetching all the posts in my "blog" pages which displaying fine, Issue is only 10 results are showing this is how I'm fetching$entries = $pages->find("template=blog-entry"); foreach($entries as $entry){ <a href='{$entry->url}'>$entry->title</a> } • By pppws hey there, i'm quite new to processwire but i'm having a great experience using it! right now i hit a point where i can't help myself out with google/searchfunction. to sketch the basic functions of my page: visitors can enter their e-mail in a form. when doing this pw creates a new page, using the e-mail's md5 hash as a name. the url of the page is sent to the user. the user now can edit the newly created page and can fill out fields like: name and year of birth (thanks to the docs those two already work like a charm!) but there are other fields like "residencies", which are repeaterfields containing three fields: city (text), country (text), current (checkbox). at my current version i can populate a new repeater field easily by using this code:$location = $page->locations->getNew();$location->location = Munich; $location->country = Germany;$location->current = 1; $location->save();$page->locations->add($location); now i want to populate the new reapter fields from input fields (using the simple form api). which leads me to my questions: 1. can i somehow group/merge input fields to one "repeater input fields" right now i have: // create a text input -> locations$field = $modules->get("InputfieldText");$field->label = __('City'); $field->attr('id+name','location');$field->required = 1; $form->append($field); // append the field to the form // create a text input -> country $field =$modules->get("InputfieldText"); $field->label = __('Country');$field->attr('id+name','country'); $field->required = 1;$form->append($field); // append the field to the form // create a checkbox -> locations$field = $this->modules->get('InputfieldCheckbox');$field->attr('name', 'location_current'); $field->attr('autocheck', 1);$field->attr('uncheckedValue', 0); $field->attr('checkedValue', 1);$field->attr('value', $this->fname);$form->append($field); // append the field to the form 2. my desired layout for the form looks like this: by hitting the + button a new line shows. i'm wondering what's the best practice here. can is somehow use the above mentioned code itself as a repeater, or do i have to create several (uniqe) input fields in advance and hide them afterwards (javascript)? any help is appreciated! thanks! • Hi, I've been invited by Apple to use their 'News' service for a publication in the UK. https://www.apple.com/uk/news/ A number of CMSs already have plugins to publish content via the API, however Processwire is not one (yet!) https://newsresources.apple.com/en/faq/66346243 It's slightly beyond my technical abilities but would be very interested in anyone that is willing to look at developing a Processwire Module. (for reference here is the Apple News API documentation) Update: Chapter Three have created a PHP Apple News library here https://github.com/chapter-three/AppleNewsAPI • So I have a bit of code for ad management : <?php$ads = $pages->find("parent.template=client, sort=expiration_date");$alert_count = 0; foreach ($ads as$ad) { $todaysdate = date("F j, Y H:i");$today = strtotime($todaysdate);$expireson = $ad->expiration_date;$expires = strtotime($expireson);$fiveaway = $expires - 432000; if ($today > $expires) {$alert = $alert_count=+1; echo$alert; } } //end FOREACH ?> It currently finds all the pages with a parent of "client" and then I can drill down to the pages that have "Expired" in my if statement. I wanted to get a "count" of the pages that met the if statement requirements so I could output that number in an alert at the top of the page. When it runs, it currently just prints out "1 1 1 1..." and not the total count of pages. Does anyone know of a way possibly achieving my desired output? I tried count(), but that did not quite produce my desired output.