diff --git "a/include/class-cli\\ConfigWizard.php" "b/include/class-cli\\ConfigWizard.php" new file mode 100644 index 0000000..f834844 --- /dev/null +++ "b/include/class-cli\\ConfigWizard.php" @@ -0,0 +1,137 @@ +. + +namespace cli; + +/** + * Configuration loader and wizard + * + * It can help generating a persistent configuration file + */ +class ConfigWizard { + + /** + * Require a configuration file or create one + * + * @param string $configuration_path + */ + public static function requireOrCreate( $configuration_path ) { + if( !file_exists( $configuration_path ) ) { + echo " _____________________________________ \n"; + echo "| |\n"; + echo "| WELCOME IN THE CONFIGURATION WIZARD!|\n"; + echo "|_____________________________________|\n"; + echo "\n"; + + $variables = []; + + $variables[] = self::askVariableContent( + 'mw\API::$DEFAULT_USERNAME', + "Generated username from [[Special:BotPasswords]]", + "Please paste here your generated username from [[Special:BotPasswords]]", + [ + "First of all you must choose an user to be used for your activities.", + "If you don't know if you need a new dedicated user first read your wiki bot policies.", + "If you work very slowly I think you can just use your real account. Anyway a dedicated account is better.", + "", + "Now please login in your wiki, with THAT user, and visit the page [[Special:BotPasswords]].", + "", + "From that page fill the \"Create a new bot password\" form with a useful name", + "Example name:", + " VolleyImportStuff\"", + "", + "Now from check the permissions you will use and then click again on \"Create\".", + "", + "Example generated username (note that it has '@'):", + " JhonDoo@VolleyImportStuff", + ] + ); + + $variables[] = self::askVariableContent( + 'mw\API::$DEFAULT_PASSWORD', + "Generated bot password", + "Please paste here your generated bot password", [ + "Note that it shold be very long and without '@'.", + ] + ); + + $content = implode( "\n", $variables ); + $content = "