-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆️ upgraded dependencies 🎨 pint Signed-off-by: bnomei <[email protected]>
- Loading branch information
Showing
13 changed files
with
255 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
if (! class_exists('Bnomei\Janitor')) { | ||
require_once __DIR__.'/../classes/Janitor.php'; | ||
} | ||
|
||
use Bnomei\Janitor; | ||
use Kirby\CLI\CLI; | ||
use Kirby\Cms\User; | ||
|
||
return [ | ||
'description' => 'Prints text to the terminal', | ||
'args' => [ | ||
'msg' => [ | ||
'longPrefix' => 'msg', | ||
'description' => 'Message', | ||
'defaultValue' => '', | ||
], | ||
'level' => [ | ||
'prefix' => 'l', | ||
'longPrefix' => 'level', | ||
'description' => 'Message level like out/success/error', | ||
'defaultValue' => 'out', | ||
], | ||
'time' => [ | ||
'prefix' => 't', | ||
'longPrefix' => 'time', | ||
'description' => 'Prefix message with timestamp', | ||
'noValue' => true, | ||
], | ||
] + Janitor::ARGS, // page, file, user, site, data, model | ||
'command' => static function (CLI $cli): void { | ||
$time = $cli->arg('time') ? '['.date('Y-m-d H:i:s').'] ' : ''; | ||
$level = match ($cli->arg('level')) { | ||
'success' => 'success', | ||
'error' => 'error', | ||
default => 'out', | ||
}; | ||
$user = Janitor::resolveModel($cli->arg('user')); | ||
$user = $user instanceof User ? ' ('.$user->email().') ' : ''; | ||
$msg = sprintf('%s%s%s', $time, $user, Janitor::query($cli->arg('msg').$cli->arg('data'), Janitor::resolveModel($cli->arg('model')))); | ||
|
||
$cli->{$level}($msg); | ||
|
||
janitor()->data($cli->arg('command'), [ | ||
'status' => 200, | ||
'message' => $msg, | ||
]); | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.