This commit is contained in:
parent
cc25c7f947
commit
5de62d801c
6 changed files with 252 additions and 185 deletions
61
yeswiki-move.php
Executable file
61
yeswiki-move.php
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require_once('vendor/autoload.php');
|
||||
require_once('utils.inc.php');
|
||||
|
||||
use PhpDevCommunity\DotEnv;
|
||||
use League\CLImate\CLImate;
|
||||
|
||||
$climate = new CLImate();
|
||||
$climate->description('yeswiki-move, move YesWiki like a professionnal 🌈🦄');
|
||||
|
||||
if (posix_getuid() != 0) {
|
||||
$climate->error('ERROR : this script needs root privilege to run.');
|
||||
exit;
|
||||
}
|
||||
|
||||
$absolutePathToEnvFile = __DIR__ . '/.env';
|
||||
if (file_exists($absolutePathToEnvFile)) {
|
||||
(new DotEnv($absolutePathToEnvFile))->load();
|
||||
} else {
|
||||
$climate->error('ERROR : No .env file found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
$climate->arguments->add([
|
||||
'from' => [
|
||||
'prefix' => 'f',
|
||||
'longPrefix' => 'from',
|
||||
'description' => 'Url of source wiki',
|
||||
'required' => true,
|
||||
'defaultValue' => 'https://example.com'
|
||||
],
|
||||
'to' => [
|
||||
'prefix' => 't',
|
||||
'longPrefix' => 'to',
|
||||
'description' => 'Url of destination wiki',
|
||||
'required' => true,
|
||||
'defaultValue' => 'https://destination.com'
|
||||
],
|
||||
]);
|
||||
$climate->arguments->parse();
|
||||
$from = $climate->arguments->get('from');
|
||||
$to = $climate->arguments->get('to');
|
||||
|
||||
if (empty($from) || $from == 'https://example.com' || empty($to) || $to == 'https://destination.com') {
|
||||
$climate->error('ERROR : you need a --from (the source url) and a --to (the destination url).'."\n");
|
||||
$climate->usage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$climate->bold()->underline()->out('Move a YesWiki');
|
||||
$climate->out('This will move yeswiki on <bold>'.$from.'</bold> to <bold>'.$to.'</bold>, CAREFULL the destination yeswiki will be rreplaced'."\n");
|
||||
$input = $climate->confirm('Is it all good ?');
|
||||
if ($input->confirmed()) {
|
||||
$climate->shout(
|
||||
'The yeswiki <bold>'.$from.'</bold> was successfully moved to <bold>'.$to.'</bold>, congrats ! 🎉'."\n"
|
||||
);
|
||||
} else {
|
||||
$climate->info('Ok, let\'s stop here...');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue