From fbdd9f3ac6ab1157186d03feff14c0f2769d7c35 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Wed, 5 Oct 2022 14:47:41 +0200 Subject: [PATCH 1/4] Require composer 2.3+ --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 822f8e6..fc2d606 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ } ], "require": { + "composer-runtime-api": "^2.2", "ext-zip": "*", "guzzlehttp/guzzle": "^7.5", "league/climate": "^3.8", From 9065be7988752a818e2d42651702c82119b84a13 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Wed, 5 Oct 2022 14:52:52 +0200 Subject: [PATCH 2/4] Update readme with instructions how to find the global composer folder --- README.md | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index a45ab0f..7944612 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,15 @@ The Kirby command line interface helps simplifying common tasks with your Kirby composer global require getkirby/cli ``` -Make sure to add the following to your `~/.bash_profile` (Mac OS users) or into your `~/.bashrc` (Linux users). +Make sure to add your composer bin directory to your `~/.bash_profile` (Mac OS users) or into your `~/.bashrc` (Linux users). + +Your global composer directory is normally either `~/.composer/vendor/bin` or `~/.config/composer/vendor/bin`. You can find the correct path by running … + +``` +composer -n config --global home +``` + +Afterwards, add the result to your bash profile … ``` export PATH=~/.composer/vendor/bin:$PATH @@ -24,7 +32,7 @@ export PATH=~/.composer/vendor/bin:$PATH Check if the installation worked by running the following in your terminal. ``` -kirby +kirby ``` This should print the Kirby CLI version and a list of available commands @@ -58,7 +66,7 @@ This should print the Kirby CLI version and a list of available commands ## Writing commands -You can create a new command via the CLI: +You can create a new command via the CLI: ```bash kirby make:command hello @@ -66,7 +74,7 @@ kirby make:command hello This will create a new `site/commands` folder in your installation with a new `hello.php` file -The CLI will already put the basic scaffolding into the file: +The CLI will already put the basic scaffolding into the file: ```php out() -```php +```php $cli->out('This is some simple text'); ``` ### $cli->success() -```php +```php $cli->success('This is text in a nice green box'); ``` ### $cli->error() -```php +```php $cli->error('This is red text for errors'); ``` ### $cli->bold() -```php +```php $cli->bold('This is some bold text'); ``` ### $cli->br() -```php +```php // this will create a line break $cli->br(); ``` @@ -149,7 +157,7 @@ For more available colors and formats, check out the CLImate docs: https://clima ## Arguments -Your commands can define a list of required and optional arguments that need to be provided by the user. +Your commands can define a list of required and optional arguments that need to be provided by the user. ```php Date: Wed, 5 Oct 2022 14:57:07 +0200 Subject: [PATCH 3/4] Update the version number --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fc2d606..2c06215 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "getkirby/cli", "description": "Kirby command line interface", "license": "MIT", - "version": "1.0.0", + "version": "1.0.1", "keywords": [ "kirby", "cms", From c2729d2d64825dbd1a44b398c3f896becfe9094e Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Wed, 5 Oct 2022 14:59:28 +0200 Subject: [PATCH 4/4] Sanitize command names for make:command --- commands/make/command.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/make/command.php b/commands/make/command.php index ec3180a..1972871 100755 --- a/commands/make/command.php +++ b/commands/make/command.php @@ -19,6 +19,8 @@ ], 'command' => static function (CLI $cli): void { $name = $cli->argOrPrompt('name', 'Enter a name for the command:'); + $name = str_replace(':', '/', $name); + $root = $cli->arg('global') === true ? 'commands.global' : 'commands.local'; $file = $cli->root($root) . '/' . $name . '.php';