marcus

wireshell - an extendable ProcessWire command line interface

Recommended Posts

The thing with Windows is that it doesn't automatically pick up the laravel command like *nix can, which is why a batch file needs to be created. However, because your wireshell file is looking for the vendor directory inside it's own, it doesn't work. As such, you'll need to change your request for autoload.php to this (the way Laravel's installer does it):

if (file_exists(__DIR__.'/../../autoload.php')) {
    require __DIR__.'/../../autoload.php';
} else {
    require __DIR__.'/vendor/autoload.php';
}

Then, the user can create a wireshell.bat file in a directory visible to the windows path containing this:

@echo off
php "%appdata%\Composer\vendor\wireshell\wireshell\wireshell" %*

This works on my side.

Update: If using mingw32 or cygwin, however, this isn't necessary - it's just a matter of adding %appdata%\Composer\vendor\wireshell\wireshell\wireshell to the path.

  • Like 1

Share this post


Link to post
Share on other sites

The thing with Windows is that it doesn't automatically pick up the laravel command like *nix can, which is why a batch file needs to be created. However, because your wireshell file is looking for the vendor directory inside it's own, it doesn't work. As such, you'll need to change your request for autoload.php to this (the way Laravel's installer does it):

if (file_exists(__DIR__.'/../../autoload.php')) {
    require __DIR__.'/../../autoload.php';
} else {
    require __DIR__.'/vendor/autoload.php';
}

Then, the user can create a wireshell.bat file in a directory visible to the windows path containing this:

@echo off
php "%appdata%\Composer\vendor\wireshell\wireshell\wireshell" %*

This works on my side.

Update: If using mingw32 or cygwin, however, this isn't necessary - it's just a matter of adding %appdata%\Composer\vendor\wireshell\wireshell\wireshell to the path.

Thanks for the support on this - I'll outline the cygwin scenario in the installation instructions.

/edit: Updated start post and WS to 0.3.1 :)

Share this post


Link to post
Share on other sites

Perfect - any time. Oh, and I made a mistake. When using cygwin/mingw32, the path is actually "%appdata%\Composer\vendor\wireshell\wireshell\". I added in an extra wireshell there...

Share this post


Link to post
Share on other sites

Big update! Version 0.3.0 comes with:

  • a new "NewCommand" provided by HariKT! Big thanks again. This contribution should lead to a better workflow with Wireshell since it opens up the possibility to install PW via command line in a convenient way
  • A command for creating fields
  • A command for assigning fields to existing templates
  • A generic backup command (DB dump)
  • Commands for en/disabling modules (downloading them via Wireshell is still on my bucket list)
  • A little command outputting the currently installed ProcessWire version
  • An unified approach to naming commands and classes: entity:verb, so for example user:create
  • I dropped the "(Experimental)" from the topic's title  ;)

Read more about the available new commands and their options in the readme.

If you have an older version of Wireshell installed, make sure you "$ composer update" it in order to get the new dependencies. And we're on packagist now: https://packagist.org/packages/wireshell/wireshell

So far so good :D .

for the command wireshell backup:db I suggest renaming it to db:backup 

so for example if you implement a db replace or db merge command in the future.

the command will became.

db:backup // Dumps an entire db
db:replace // Delete existing db and replace it with a backed one
db:merge // Merge the existing db with the data from a backed one

Again thanks for the great work.

Share this post


Link to post
Share on other sites

So far so good :D .

for the command wireshell backup:db I suggest renaming it to db:backup 

so for example if you implement a db replace or db merge command in the future.

the command will became.

db:backup // Dumps an entire db
db:replace // Delete existing db and replace it with a backed one
db:merge // Merge the existing db with the data from a backed one

Again thanks for the great work.

Thanks! The idea behind backup:db is that backup is the entity/namespace, and you can specify:

:db for database

:files for /site/assets/files

:scripts for all scripts (/site + /wire + root files)

:all for :scripts + :db

  • Like 3

Share this post


Link to post
Share on other sites

Marcus, this looks fantastic, thanks for all your hard work!

Not hard at all - fun, as I'm dealing with amazing tools (ProcessWire, Symfony, Composer packages) and learn a lot on the way :)

  • Like 7

Share this post


Link to post
Share on other sites

I've just started a new project and decided to test/use Wireshell.

After I had successfully created a new project I missed the opportunity to download modules. You've received a new pull request^_^ Maybe you have some time to test (and hopefully implement) it.

  • Like 9

Share this post


Link to post
Share on other sites

Just received the mail from GitHub! Nice! Trying it out over the weekend! Big thanks!

Share this post


Link to post
Share on other sites

This seems to gain some traction, great job @marcus :)

  • Like 2

Share this post


Link to post
Share on other sites

Finally I have had time to download it. Its simply fantastic and a lot of fun! :)

Regarding the windows users I share how I have set it up. Its only a bit slightly different than the very good explanation here from @marcus and @Mike_Anthony. I have done installation step 1 and 2, but not step 3. Instead of adding something to my path I simply created a single wireshell.bat file that I put somewhere into my already existing system path.

I also have no PHP directory accessible through the system path, because I use minimum 5 different PHP versions (3 for CLI and 2 with the local Apache). If there were one in the system path this can lead to weird behavior of PHP, at least with the old PHP 4 that I need for older CLI tasks. :)

My wireshell.bat looks like

@ECHO OFF
SET phpexe=C:\bin\php-54\php.exe
SET phpparams=-c C:\bin\php-54\wireshell\
SET wireshell=%appdata%\Composer\vendor\wireshell\wireshell\wireshell

TITLE WIRESHELL :: %CD%
"%phpexe%" %phpparams% "%wireshell%" %*
TITLE %CD%

With the phpparam -c I have specified a directory where the php interpreter has to pickup its php.ini. I have one setup that is different than I need with other CLI scripts. I also could have linked to the php directory what is running under apache. But unfortunately I switch this between php 5.3.8 and 5.4.x for modules testing currently. (and composer and wireshell needs minimum 5.4.0)

That with setting the title in the cli windows is nice if you have running several tasks. When hovering over the stacked icons on the taskbar, you can see which one is in "WIRESHELL mode" and which one is finished. :)

post-1041-0-89062800-1429395080_thumb.pn

post-1041-0-67908800-1429395092_thumb.pn

  • Like 5

Share this post


Link to post
Share on other sites

justb3a's great ModuleDownloadCommand has just hit the develop branch! Next, I'll try to incorporate Nico's module generator, and then both new Commands will be released as 0.4.0 :)

@horst: Thanks for sharing your approach! Since the Readme and this topic's start post is getting bigger and bigger I'll set up a dedicated microsite for wireshell doc and best practices like these.

  • Like 7

Share this post


Link to post
Share on other sites

marcus I really like where this is heading. keep up the great work!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, felix!

New on develop branch:
 

$ wireshell status

(Replacing ShowAdminUrlCommand, ShowVersionCommand)

wireshell-status.gif

Edited by marcus
  • Like 6

Share this post


Link to post
Share on other sites

Thank you for putting this together. This is absolutely great :)

I came over from Joomla some time ago and one of the many joomla devs have created joomla-console. They combine it with their joomla-vagrant box which is a great tool for development. I am actually still using it for quick setup of PW projects  ;) And I've been thinking for quite some time how great it would be to have a console tool for PW. And now it is here. So big thumbs up!

I see that there is some kind of naming convention for commands now. Have you ever considered renaming the 'new' to 'site:create' Thats what joomla-console uses and they also have a 'site:delete'.

Share this post


Link to post
Share on other sites

I see that there is some kind of naming convention for commands now. Have you ever considered renaming the 'new' to 'site:create' Thats what joomla-console uses and they also have a 'site:delete'.

I think the context may be wrong. I don't know Joomla at all, but, to me, site:create would imply a multi-site environment, especially considering the existence of site:delete. Or am I wrong?

Share this post


Link to post
Share on other sites

@marcus, when I have read this about status, it came to my mind that we already have those Diagnostic Tools. Do you already know them?

Maybe it is possible to integrate some of the submodules into wireshell by calling status:(submodule)?

post-1041-0-39532900-1429966323_thumb.jp

post-1041-0-25733900-1429966342_thumb.jp

Edited by horst
added screenshots
  • Like 4

Share this post


Link to post
Share on other sites

That's a good idea!

Instead of status:submodule I'd suggest to add it as options, like:
 

$ wireshell status --php --filesystem --image --webserver

...and output each block/topic as a separate table (see screenshot above).

Without options wireshell status would just return the PW and wireshell info.

Either way: I'll look into Diagnostic Tools as soon as I finish 0.4.0 and the project microsite. Of course pull requests for this, maybe from the Diagnostic Tools creators & contributors themselves, would be highly appreciated :)

  • Like 2

Share this post


Link to post
Share on other sites

I think the context may be wrong. I don't know Joomla at all, but, to me, site:create would imply a multi-site environment, especially considering the existence of site:delete. Or am I wrong?

In the joomla-vagrant context it makes perfect sense because with that command you can setup a new site in a subdomain so you can have multiple dev sites residing in one virtual machine. But I see your point when considering multi site environments.

Share this post


Link to post
Share on other sites

Of course pull requests for this, maybe from the Diagnostic Tools creators & contributors themselves, would be highly appreciated :)

Hehe, started! ;):biggrin:

post-1041-0-12706300-1429985194_thumb.pn

  • Like 4

Share this post


Link to post
Share on other sites

People, this is really awesome!  ^-^ 

When I started this little project I had a little hope for community contributions a) because of the vibrant PW community and b) the modular architecture of Symfony Console, but I would have never expected this growth within a month. Big thanks to all contributing and fixing commands and ideas! 

@horst: Bam! Delivered! Cheers!  :P I'll look into it, merge it soon and will establish a proper namespace for the growing number of helper classes.

One more thing: I hate to have hobby horse projects without at least a rudimentary logo  :biggrin: 

ws_draft.gif
 

  • Like 4

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      I am wondering, how do you pass a variable into wire('page')->get() inside a function? I have been looking through the forums, but unfortunately I have not found the answer yet.
      My current set up is:
      function generateNewPages($parentPageName) { $p = new Page(); $p->template = "parent"; $p->parent = wire('pages')->get('/home/'); $p->name = $parentPageName; $p->title = $parentPageName; $p->of(false); $p->save(); $p2 = new Page(); $p2->template = "child"; $p2->parent = wire('pages')->get('$parentPageName'); $p2->name = "child"; $p2->title = "Child Page"; $p2->of(false); $p2->save(); } When I try to run it by passing in a title like generateNewPages('Demo');, "Demo" is created, but when it gets to the child page I get:
      Unknown Selector operator: '$' -- was your selector value properly escaped?
      Is there a way to pass the $parentPageName to "wire('pages')->get('$parentPageName')" ?
    • By thomasaull
      I recently started to build Vue SPAs with ProcessWire as the backend, connected with a REST API. Thanks to code and the help of @LostKobrakai (How to use FastRoute with ProcessWire) and @clsource (REST-Helper) I got it up and running pretty quickly and now have put all of it in a site profile for others to use. It includes the REST API with routing for different endpoints, JWT Auth and a simple Vue SPA which shows the process of logging in a user (nevertheless, you don't have to use the Vue part, the API will work on it's own).
      Check it out here: https://github.com/thomasaull/RestApiProfile
      I'm pretty sure, it's not the perfect or most sophisticsted solution, but it gets the job done for me…
      Feedback or Improvements are very welcome
      Update: This site profile is a module now: https://github.com/thomasaull/RestApi
    • By Pixrael
      I have a technical question that maybe you can guide me to a solution/idea.
      I know an online tool that publishes product information and updates prices/inventories regularly from marketplaces such as Amazon, Ebay, etc. to a Wordpress website ... can get the orders information, auto-order it and send back the tracking numbers. All this is done through the Woocommerce API. They don't have an API or CSV option to access this features..
      Is it possible to create fake REST endpoints (a clone of WooCommerce) on my site to accept requests from that external website and process this data my way inside PW? The requests to a REST endpoint are POST like in regular forms submits?
      Sorry I don't have to much technical background about this
      https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-a-product https://woocommerce.github.io/woocommerce-rest-api-docs/?php#update-a-product https://woocommerce.github.io/woocommerce-rest-api-docs/?php#retrieve-an-order
    • By Xonox
      Hi,
       
      I'm trying to upload images from a folder into a page. I need to replace the images instead of adding. The image field already has the replace existing images turned on, but it doesn't seem to be enough.
       
      My code:
      foreach($files as $file) { if(substr($file, 0, 1) != '.' && $file != '.' && $file != '..') { // Get SKU $file_sku = substr($file, 0, 9); // Check for book $book = $pages->get('sku=' . $file_sku); if(!$book->id) { // Book doesn't exist } else { // Upload image into book !!! THIS CODE ADDS FILE INSTEAD OF REPLACING. HOW CAN I REPLACE? $book->book_images->add($upload_directory . '/' . $file); // Delete file unlink($upload_directory . '/' . $file); } // Save book if($book->id) $book->save(); } }  
      What am I missing?
    • By louisstephens
      I have a repeater with a text field where I would like to use hanna code (to make it easier on the user) so the user can define the action of a image that is in the repeater. For example:
      1. The image should have an external link:
      - the user can just type in the url
      2. The image, when clicked, should be printable (using print.js)
      - the user can just type [[print_image]]
      That works just fine, but I am running into an "issue". The code I need to use to print is:
      onclick="printJS({printable: 'path_to_image', type: 'image'});" I can put that into the hanna code as plain text, but I have no idea how to get the image from the repeater item and pass to "path_to_image". Is this even possible?