marcus

wireshell - an extendable ProcessWire command line interface

Recommended Posts

I am running version 5.4.37 on Mac 10.9. 

Ah, on said line is an PHP expression that only works on PHP 5.5. I guess I fixed it in the latest dev. You should be able to grab it via

composer global require wireshell/wireshell:dev-develop

Share this post


Link to post
Share on other sites

And now the next error:

composer global require wireshell/wireshell:dev-develop                                                                                           15:38:42

Changed current directory to /Users/lpa/.composer

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

  - Updating wireshell/wireshell (0.4.0 => dev-develop 33ef0ed)

    Checking out 33ef0eda3d1b182c5c14a51603e80dd6cfe0d377

 

Writing lock file

Generating autoload files

 

wireshell

 

PHP Fatal error:  Can't use method return value in write context in /Users/lpa/.composer/vendor/wireshell/wireshell/src/Commands/User/UserListCommand.php on line 62

PHP Stack trace:

PHP   1. {main}() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

PHP   2. require() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:5

PHP   3. Composer\Autoload\ClassLoader->loadClass() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

PHP   4. Composer\Autoload\includeFile() /Users/lpa/.composer/vendor/composer/ClassLoader.php:301

 

Fatal error: Can't use method return value in write context in /Users/lpa/.composer/vendor/wireshell/wireshell/src/Commands/User/UserListCommand.php on line 62

 

Call Stack:

    0.0002     229376   1. {main}() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

    0.0005     246808   2. require('/Users/lpa/.composer/vendor/wireshell/wireshell/app/wireshell.php') /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:5

    0.1050    1695728   3. Composer\Autoload\ClassLoader->loadClass() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

    0.1050    1695880   4. Composer\Autoload\includeFile() /Users/lpa/.composer/vendor/composer/ClassLoader.php:301

Share this post


Link to post
Share on other sites

Dang! I missed one occurence of that error. Sorry. Please 'composer global require wireshell/wireshell:dev-develop' again, => dev-develop 88c5ae should now appear.

Share this post


Link to post
Share on other sites

And now:

PHP Fatal error:  Can't use method return value in write context in /Users/lpa/.composer/vendor/wireshell/wireshell/src/Commands/Module/ModuleDownloadCommand.php on line 81

PHP Stack trace:

PHP   1. {main}() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

PHP   2. require() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:5

PHP   3. Composer\Autoload\ClassLoader->loadClass() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

PHP   4. Composer\Autoload\includeFile() /Users/lpa/.composer/vendor/composer/ClassLoader.php:301

 

Fatal error: Can't use method return value in write context in /Users/lpa/.composer/vendor/wireshell/wireshell/src/Commands/Module/ModuleDownloadCommand.php on line 81

 

Call Stack:

    0.0002     229344   1. {main}() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

    0.0005     246776   2. require('/Users/lpa/.composer/vendor/wireshell/wireshell/app/wireshell.php') /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:5

    0.0726    1895576   3. Composer\Autoload\ClassLoader->loadClass() /Users/lpa/.composer/vendor/wireshell/wireshell/wireshell:0

    0.0727    1895736   4. Composer\Autoload\includeFile() /Users/lpa/.composer/vendor/composer/ClassLoader.php:301

Share this post


Link to post
Share on other sites

Sorry for being tester here. Please try again, you should catch commit 3ddb7a now.

Share this post


Link to post
Share on other sites

Yes, it works now! Thanks!

Share this post


Link to post
Share on other sites

Now just an annoying thing when I have notices on I get this on every command. Maybe I should set notices off. 

PHP Notice:  Undefined index: REQUEST_URI in /Library/WebServer/Documents/encanto/site/modules/HelperFieldLinks/HelperFieldLinks.module on line 37

Share this post


Link to post
Share on other sites

@lpa: looks like an issue with the Helper Field Links module, you might want to report it to Soma in the appropriate thread. It's incorrect behaviour to expect REQUEST_URI to always be present.

Share this post


Link to post
Share on other sites

For those who want to upgrade to the latest core version like me, I added the following command:

Common
 
Upgrade
 
Checks and optionally installs core upgrades.
$ wireshell upgrade
Available options:
$ wireshell upgrade --dev --just-check --just-download
Output Example
❯ wireshell upgrade

A ProcessWire core upgrade is available master 2.6.0

  Downloading ProcessWire Version 2.6.0...
    9.35 MB/9.35 MB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%

  Preparing new core version...

  Upgrade files copied.
  Installing new core files.

  Your index.php file is confirmed identical to the one included
  with ProcessWire version 2.6.0 so it should be safe to replace
  without further analysis.

  We have detected that your .htaccess file may contain site-specific
  customizations. Please double check before replacing it.

  Upgrade completed.
  Now double check that everything works.
  You have to replace htaccess.txt manually.

A lot of the code is taken from Ryan's ProcessWireUpgrade Module.

  • Like 3

Share this post


Link to post
Share on other sites

Bea's great contribution is now on dev :) Before it hits master, one thing though: When I tested it, I ran in some file permission problems. But I'm not sure whether it is connected to my particular setup, or MAMP.

It would be really great if some of you could grab the develop branch

composer global require wireshell/wireshell:dev-develop

and do a little test drive, and see if the updated PW installation throws a white page/500, connected to file permissions - or not. Cheers!

Share this post


Link to post
Share on other sites

Which files / folders cause the CHMOD issue? We should check this at the beginning, throw an exception or change the permissions on the fly. I guess the best approach would be to tell the users there are missing permissions and whether we should change them (using a prompt).

Share this post


Link to post
Share on other sites

It seems to be the wire folder, and the index.php in root. After upgrade they got 700 (wire) and 644 (index.php). Still, I'm not sure how general of a problem this is.
On alternative approach to your proposal is to chmod these files via PHP, wouldn't it?

Share this post


Link to post
Share on other sites

... or change the permissions on the fly.

means exactly  ;) :

On alternative approach to your proposal is to chmod these files via PHP, wouldn't it?

Share this post


Link to post
Share on other sites

means exactly  ;) :

Right, must have skipped that part while reading ;)

Share this post


Link to post
Share on other sites

Regarding this permissions-after-upgrade-issue, I just pushed a prompt to dev branch as you've suggested, b3a.

I'm still not sure whether I just tailored it for my setup and it's issues, or MAMP usage in general. Anyway, it should not hurt the command to have it there.

Share this post


Link to post
Share on other sites

Welcome, justb3a and clsource, as core contributors to wireshell! We got a dedicated GitHub organization now:  https://github.com/wireshell/wireshell - please update the remotes of your forks  :) Packagist reference is already updated, to the usual $ composer global require wireshell/wireshell will work like before.

The three of us are now toying around ideas how to improve wireshell, and one big feature would be if ProcessWire modules could provide their own wireshell commands (in addition to the wireshell core commands). We're not sure how to do this exactly, but maybe the PW community/module authors have ideas.

Our current scenario:
Besides from scanning its own /src/Commands folder for core commands (right now commands are hard-coded in /app/wireshell.php), thanks Stikki for the idea!, wireshell could search inside (ProcessWire's) /site/modules/ folder for commands provided by modules. So for example, alongside /site/modules/MyAmazingModule.module there can be a MyAmazingModuleCommand.php file (or commands, or "namespace" folder if there are more than one). The things bugging me here are a) dealing with dependencies and b) the exact details of "scanning for commands". But maybe someone could chime in here? I guess a concept of "PW module provided wireshell commands" would be a huge step forward (Drupal's drush already works this way, and makes it a really, really useful tool)

Edited by marcus
  • Like 3

Share this post


Link to post
Share on other sites

Hey @marcus 

Regarding the module downloads, I am not sure if you noticed my earlier posts

http://harikt.com/blog/2013/11/16/composer-support-for-processwire-modules/

http://harikt.com/blog/2013/11/19/composer-support-for-processwire-part-2/

That way we can install modules on the site/modules folder as we are doing with just composer.

I am also missing how processwire will support composer in the future, if anyone can give some insights / links it may also help.

EDIT : I am happy to change the vendor name and give to processwire if Ryan likes it.

Thank you

  • Like 2

Share this post


Link to post
Share on other sites

Hi Hari,

you're right - I read them back in 2013, but forgot until now - thanks!

Composer could be the solution here regarding dependencies  :) I'm also very interested in how PW3 will support it. The last PW blog post on this topic reads promising!

Share this post


Link to post
Share on other sites

Hey Marcus, 

Yes as dependency is a hell it is good to leave it to composer ;) . And as you know installing modules is simple as 

composer require <vendor/packagename>

The only thing to do is to keep a composer.json file for all the modules

{
    "name": "vendor/package-name",
    "type": "pw-module",
    "description": "Your module what it does",
    "keywords": [ "keywords", "comma", "seprated"],
    "homepage": "https://github.com/harikt",
    "license": "BSD-2-Clause",
    "authors": [
        {
            "name": "Contributors",
            "homepage": "https://github.com/harikt"
        }
    ],
    "require": {
        "hari/pw-module": "~0.0.1"
    }
}

and add to packagist. The only things to note in composer.json is the 

"type": "pw-module",

and 

"require": {
    "hari/pw-module": "~0.0.1"
}

We are all done. 

Happy PhPing!

  • Like 2

Share this post


Link to post
Share on other sites

Good morning, wireshell 0.5.0!

ws050-1.png

ws050-2.png

This great justb3a-driven update to wireshell add some more goodies to our little command line companion, such as:

  • ProcessWire core update via command line
  • Page command context: Create, List, Delete pages from wireshell, empty the trash. Listing can start at ID 1 or any other page/ID
  • Adds backups of image assets to backup command context
  • List all available templates, including system ones
  • Delete templates via wireshell
  • Clone fields via field:clone
  • wireshell runs now from everywhere within your PW installation, not just its root folder
     

As always, further documentation can be found on http://wireshell.pw

Keep in mind that we're still on a version number below 1, therefore in an experimental state - use wireshell with caution and backup before critical operations. Also, drop us a line if you run into dependency problems (such as trouble with symfony/console).

Happy CLIng!

  • Like 5

Share this post


Link to post
Share on other sites

Just noticed that there is a CLI Tool for ProcessWire, and even before giving it a try I just want to say *thanks* to the author.

CLI Tools, generators, preprocessors and stuff, modern web dev' & design is really helpful and the way to go.

\o/

  • Like 1

Share this post


Link to post
Share on other sites

Hey guys,

couple of notes:

- you haven't "released" the 0.5.0 on the GitHub, so composer tries to install 0.4.1

- on the site, the composer --globally link (in the install) has a couple of spaces between '00-intro' and '.md', so it 404s

- on the site, you don't see the whole navigation, and it isn't scrollable under 900px I think (as in: 1280x800 macbook :)

Also, I can't install 0.4.1 due to guzzlehttp/streams issue (I have global 3.0.0 installed); will wait vor the 0.5.0 version and report then if it doesn't work.

Thanks

Share this post


Link to post
Share on other sites

Thanks for the report on these issues. My bad. Version is now properly tagged. Regarding the scrolling issue on wireshell.pw: Odd, since it is overflow auto

edit: Broken link is fixed

Share this post


Link to post
Share on other sites

0.5.0 is now released  ^_^  Thanks for the hint.

I have no access to the site, therefore I'm not able to fix those issues.

edit: ... too slow^^

Share this post


Link to post
Share on other sites

Install:

Right, a global lumen installer from laravel requires guzzlehttp/*, but newer versions, so wireshell couldn't be installed (maybe a note in the docs?).

Thanks, guys

Re: scrolling

It might be just Safari, which seems to work in mysterious ways.

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?