Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
2 Star 0 Fork 0

积木云插件/开发辅助

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
main
Branches (1)
main
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
main
Branches (1)
main
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
main
Branches (1)
main
xbDeveloper
/
command
/
PluginCreate.php
xbDeveloper
/
command
/
PluginCreate.php
PluginCreate.php 6.36 KB
Copy Edit Raw Blame History
<?php
/**
* 积木云渲染器
* @package XbCode
* @author 楚羽幽 <958416459@qq.com>
* @license Apache License 2.0
* @link http://www.xbcode.net
* @document http://doc.xbcode.net
*/
namespace plugin\xbDeveloper\command;
use plugin\xbDeveloper\api\PluginsCreate;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* 创建插件
* @copyright 贵州积木云网络科技有限公司
* @author 楚羽幽 958416459@qq.com
*/
class PluginCreate extends Command
{
protected static $defaultName = 'xb-plugin:create';
protected static $defaultDescription = 'Xb Plugin Create';
/**
* 配置命令
* @return void
* @copyright 贵州积木云网络科技有限公司
* @author 楚羽幽 958416459@qq.com
*/
protected function configure()
{
$this->addOption('title', 'title', InputOption::VALUE_OPTIONAL, 'Xb plugin title');
$this->addOption('name', 'name', InputOption::VALUE_OPTIONAL, 'Xb plugin name');
$this->addOption('author', 'author', InputOption::VALUE_OPTIONAL, 'Xb plugin author');
$this->addOption('desc', 'desc', InputOption::VALUE_OPTIONAL, 'Xb plugin description');
$this->addOption('gradient', 'gradient', InputOption::VALUE_OPTIONAL, 'Use gradient background (y/n)', 'n');
}
/**
* 执行命令
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
* @copyright 贵州积木云网络科技有限公司
* @author 楚羽幽 958416459@qq.com
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
// 检查是否通过命令行参数传入
$title = $input->getOption('title');
$name = $input->getOption('name');
$author = $input->getOption('author');
$desc = $input->getOption('desc');
$gradientOption = $input->getOption('gradient');
$gradientOption = strtolower($gradientOption);
$quick = true;
// 如果没有通过命令行参数传入,则使用交互式询问
if (empty($title)) {
$question = new Question('插件标题 (title):');
$title = $helper->ask($input, $output, $question);
$quick = false;
}
if (empty($name)) {
$question = new Question('插件标识 (name):');
$name = $helper->ask($input, $output, $question);
$quick = false;
}
if (empty($author)) {
$question = new Question('开发者名称 (author):');
$author = $helper->ask($input, $output, $question);
$quick = false;
}
if (empty($desc)) {
$question = new Question('一句话描述 (3-30字):');
$desc = $helper->ask($input, $output, $question);
$quick = false;
}
// 验证必填字段
if (empty($title)) {
$output->writeln("<error>插件标题不能为空</error>");
return self::FAILURE;
}
if (empty($name)) {
$output->writeln("<error>插件标识不能为空</error>");
return self::FAILURE;
}
if (empty($author)) {
$output->writeln("<error>开发者名称不能为空</error>");
return self::FAILURE;
}
if (empty($desc)) {
$output->writeln("<error>一句话描述不能为空</error>");
return self::FAILURE;
}
// 检测标识必须字母+数字
if (!preg_match('/^[a-zA-Z0-9]+$/', $name)) {
throw new \Exception('插件标识只能是字母+数字,不能包含特殊字符');
}
// 处理渐变色选项
if ($gradientOption === 'y' || $gradientOption === 'yes') {
$gradient = true;
} elseif ($gradientOption === 'n' || $gradientOption === 'no') {
$gradient = false;
} else {
// 如果没有有效的命令行参数,则询问用户
$question = new ConfirmationQuestion('渐变色预览图?(y/n):');
$gradient = $helper->ask($input, $output, $question);
}
$gradientText = $gradient ? '是' : '否';
try {
// 创建参数
$data = [
'title' => $title,
'name' => $name,
'author' => $author,
'desc' => $desc,
'gradient' => $gradient,
];
// 数据验证
PluginsCreate::validate($data);
// 是否快速创建
if (!$quick) {
// 输出插件创建信息
echo "\n";
$output->writeln("<info>----------插件信息----------</info>");
$output->writeln("<info>插件标题:{$title}</info>");
$output->writeln("<info>插件标识:{$name}</info>");
$output->writeln("<info>开发者名称:{$author}</info>");
$output->writeln("<info>一句话描述:{$desc}</info>");
$output->writeln("<info>是否使用渐变色背景:{$gradientText}</info>");
$output->writeln("<info>----------插件信息----------</info>");
echo "\n";
// 创建确认提示
$question = new ConfirmationQuestion('认真确认信息后,是否创建插件?(y/n)', false);
if (!$helper->ask($input, $output, $question)) {
return self::SUCCESS;
}
echo "\n";
}
// 开始创建插件
$output->writeln("正在创建 {$name} 插件...");
PluginsCreate::create($data, true);
} catch (\Throwable $th) {
$output->writeln("<error>{$th->getMessage()}</error>");
return self::FAILURE;
}
$output->writeln("<info>{$name} 插件创建成功...</info>");
return self::SUCCESS;
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

基于积木云框架的开发者辅助插件
Cancel

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/xbcode-plugin/xbDeveloper.git
git@gitee.com:xbcode-plugin/xbDeveloper.git
xbcode-plugin
xbDeveloper
开发辅助
main
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /