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 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.