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 Harmen
      I want to add a few pages to an AsmSelect Page field inside a repeater using the following code:
      $trialsPage = wire("pages")->get(28422); // Get the page $trialsPage->of(false); $newTrial = $ordersPage->trial_repeater_orders->getNewItem(); // Add item to repeater foreach ($selectedProducts as $selectedProduct){ $productPage = $pages->get("template=product, reference=$selectedProduct"); $newTrial->trial_selected_products->add($productPage); } $newTrial->save(); $trialsPage->save(); However, when I check the page where the field is located it doesn't have the new values as expected. The selected pages exist, the field is in the right location, made sure that the output formatting is turned off: $page->of(false); But it still doesn't work with a variable. No matter what I try, it doesn't work.
      It only works when I replace $selectedProduct with a hardcoded string. Am I doing something wrong here?
    • By louisstephens
      So I have been diving into hooks lately, and I am enjoying them thus far. However, I guess I am a bit stumped on how to achieve what I want too. I am trying to set up a hook that would create a new child page when the parent page is saved. However, when you save the parent page a second time, I just need to update the child page without creating multiple child pages. What would be the best way to go about this?
      So after rereading my post, I believe it is a bit vague so I will try to explain more. 
      The Goal:
      Create a page with a template "one". Once the page is created/saved => create a new child page with the template of "two" If the parent is saved anytime after, do nothing to the child page (limit the parent page to one child page) The parent page is really just being used to output content, whereas the child page is being used to pull out the some fields from the parent to be used elsewhere. I might have made this too complicated in my head.
    • By Peter Knight
      Is there a way to make JPGs progressive by default via the API?
      I've added the following to my site/config.php file but user-uploaded images are often displayed as non progressive.
      $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'interlace' => true, // use interlaced JPEGs by default? (recommended) 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 95, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => 0.5, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) ); Thanks
    • By louisstephens
      From my last post, I was given a good idea on how to count the repeater items, and it worked wonderfully. I got my code working well and the columns (based on the count) all work well as well. Now, I have a head scratcher on my hands. 
      <?php $buttonsIncluded = $page->special_custom_buttons->find('special_custom_buttons_include=1'); $buttonsIncludedCount = count($buttonsIncluded); $buttonsIncludedCountAdditional = $buttonsIncludedCount +1; echo $buttonsIncludedCount; ?> <div class="row"> <?php foreach($buttonsIncluded as $button): ?> <?php if($button->custom_buttons_include): ?> <?php if($buttonsIncludedCountAdditional == 2): ?> <div class="col-6"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php elseif($buttonsIncludedCountAdditional == 3): ?> <div class="col-4"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php elseif($buttonsIncludedCountAdditional == 4): ?> <div class="col-3"> <a href=""><?php echo $button->custom_buttons_text; ?></a> </div> <?php endif; ?> <?php endif; ?> <?php endforeach; ?> </div> All of this is included in a larger foreach statement that is pulling in other data (like body copy etc etc) from a Page Table field. As you can see in my code above, I am adding "1" to the count, so I can have space in the grid layout for a new button.
      So, right now: it looks something like: 
      [repeater button] [repeater button] [repeater button] [space for new button] What I really need to do is to pull in the button from the Page Table and add it into the new space so it looks like:
      [repeater button] [repeater button] [repeater button] [button from Page Table] Is this even possible todo, or is there a better way to go about this? 
       
      *Edit*
      So, I really just overlooked something quite easy here. Since the grid is based on 12 columns, I could just take 12 and divide by $buttonsIncludedCountAdditional which would give me the remaining col width to use outside the foreach loop. I was trying to make this too complicated.
    • By louisstephens
      Is it possible to use count() to return a number of repeater items don't have a checkbox checked? In my current set up, I have a repeater on the page "dev_repeater" with a checkbox called "dev_repeater_exclude". I need to get a count of the current items that do not have it checked so I can pass it to my css grid to alter the column width.