Jump to content

wire-cli - A CLI Tool for ProcessWire Developers


flydev
 Share

Recommended Posts

You can find here the release of wire-cli, successor to wire shell, a powerful command-line interface (CLI) tool designed specifically for ProcessWire developers. Optimize your workflow, automate repetitive tasks, and manage your ProcessWire projects with ease.

Wire-cli leverages the Symfony Console Component to provide a robust CLI experience, offering a wide range of features and commands to enhance your development process. From creating new projects and managing fields, templates, roles, and users, to performing database backups and serving your ProcessWire projects with a built-in web-server.

Still in development, there might be some glitch, I will continuously improve and expand its functionality based on the feedback and needs of the ProcessWire community. Also mentioning that we will be probably working towards merging the features of wire-cli and rockshell to provide a unified CLI solution for ProcessWire.

To get started with wire-cli, check out the GitHub repository or simply install it now from your terminal using Composer:

composer global require wirecli/wire-cli

Contributions are welcome. If you encounter any issues or have suggestions for improvements, please submit an issue, a pull request or post it here.

 

horizontal-alpha-png24.png.f35e4e3966778f9e34531a1dc57630fe.png

  • Like 18
  • Thanks 2
Link to comment
Share on other sites

Sounds super cool! The wire shell project was one of the greatest tools in the PW ecosystem. Glad it is reborn!

Especially great to hear that there are plans to work on a unified solution with @bernhard's RockShell. A true community spirit! AFAIK RockShell has a lot of Rock*-specific stuff. So maybe need to think about the expandable architecture right away?

Would love to test and contribute.

P.S. Can't save wire shell in a single word. Is there some smart spell checking and correction going on now and how do I get around it, @Pete)))

  • Like 3
Link to comment
Share on other sites

  • 7 months later...

Looking forward to using this, but I am running into issues. What am I missing?

After installing globally, I get

Using version ^1.4 for wirecli/wire-cli

Then when I try an run it.

wire-cli: command not found

Link to comment
Share on other sites

On 7/15/2023 at 11:55 AM, Ivan Gretsky said:

AFAIK RockShell has a lot of Rock*-specific stuff. So maybe need to think about the expandable architecture right away?

I'm not sure what you mean by that? RockShell is extendable by design. You can place your own commands either in /site/assets or in /site/modules/YourModule/RockShell/Commands/

A simple command is as simple as that:

class HelloWorld extends Command
{
  public function handle()
  {
    $this->write("Hello World!");
    return self::SUCCESS;
  }
}

Docs are here https://www.baumrock.com/en/processwire/modules/rockshell/docs/custom/ , it's actively developed (https://github.com/baumrock/RockShell/releases) and contributions are welcome.

Link to comment
Share on other sites

15 hours ago, RyanJ said:

Then when I try an run it.

wire-cli: command not found

It can be confusing as the readme contain a typo in the given example, the right command is the shorter, without a dash: `wirecli

  • Like 1
Link to comment
Share on other sites

@flydevThanks, but still getting the same:

Verified its installed:
wirecli/wire-cli                 1.4.11  An extendable ProcessWire command line interface

Command:
wirecli -help

Output:
wirecli: command not found

Link to comment
Share on other sites

  • 3 weeks later...

You can probably find the executable file from /home/<username>/.config/composer/vendor/bin -folder so running /home/<username>/.config/composer/vendor/bin/wirecli should work. If you want to use it without the path you should add that path to your shell $PATH-variable.

  • Like 5
Link to comment
Share on other sites

On 3/14/2024 at 2:55 PM, RyanJ said:

wirecli: command not found

Ran into the exact same problem a few minutes ago.

Verified the [home] of composer with this:

composer config --list --global

And finally added it to my $PATH in .bashrc

export PATH="$PATH:~/.config/composer/vendor/bin"

composer.png.7afcfb9161b56845ab660104b7faa160.png

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

If anyone is using wire-cli, and you find you're getting a lot of PHP warnings about not being able to set session parameters after headers have been sent, this may help. You may need to add a custom session function to site/config.php to prevent ProcessWire attempting to setup session handling when it's bootstrapped by wire-cli from the command line.

YMMV, but this seems to be working for me.

NOTES:

  1. Adjust the path if your admin interface is not at /processwire/.
  2. If you need sessions on the public (non-admin) paths of your site, remove the "ADJUST THIS PATH..." line and change the final line to "return true;".
/**
 * Custom Session Control
 *
 * - Keeps non-admin pages free of cookies/sessions
 * - Unless there is already a session cookie
 * - Prevents session start on CLI invocation (wire-cli etc.)
 * - Allows admin pages to use sessions
 */
$config->sessionAllow = function($session) {
    if ($session->hasCookie()) return true;
    $req_uri   = $_SERVER['REQUEST_URI'] ?? false;
    if (false === $req_uri) return false; // CLI invocation?
    if (0 === strpos($req_uri, '/processwire/')) return true; // ADJUST THIS PATH IF NEEDED
    return false;
};
  • Like 2
Link to comment
Share on other sites

  • 4 months later...

Good day Wire-cli users!

I am here to say thanks to @flydevfor his recent small but game-changing fix. This now allows to automate PW installation via script more easily. And you don't have to have Wire-cli installed globally.

# clone the repo
git clone https://github.com/wirecli/wire-cli.git

# update vendors
composer update -d wire-cli/

# check if the tool is working
php wire-cli/wirecli -V

# install PW
php wire-cli/wirecli new --force [...other options here]

@Jonathan Lahijani, I remember you were interested in this.

  • Like 2
Link to comment
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
 Share

×
×
  • Create New...