fix: update envision-cli tools for proxy and run app
This commit is contained in:
30
src/command/proxy.ts
Normal file
30
src/command/proxy.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { program, Command } from '@/program.ts';
|
||||
import { chalk } from '@/module/chalk.ts';
|
||||
import inquirer from 'inquirer';
|
||||
|
||||
const command = new Command('proxy')
|
||||
.description('执行代理相关的命令')
|
||||
.option('-s, --start', '启动代理')
|
||||
.option('-u, --unset', '关闭代理')
|
||||
.action((options) => {
|
||||
const proxyShell = 'export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890';
|
||||
const unProxyShell = 'unset https_proxy http_proxy all_proxy';
|
||||
|
||||
if (options.start) {
|
||||
console.log(chalk.green('启动代理'));
|
||||
console.log(chalk.green('执行以下命令以启用代理:'));
|
||||
console.log(`\n ${chalk.yellow(proxyShell)}\n`);
|
||||
console.log(`请运行以下命令应用代理:`);
|
||||
console.log(chalk.cyan(`eval "$(${process.argv[1]} proxy -s)"`));
|
||||
} else if (options.unset) {
|
||||
console.log(chalk.green('关闭代理'));
|
||||
console.log(chalk.green('执行以下命令以禁用代理:'));
|
||||
console.log(`\n ${chalk.yellow(unProxyShell)}\n`);
|
||||
console.log(`请运行以下命令取消代理:`);
|
||||
console.log(chalk.cyan(`eval "$(${process.argv[1]} proxy -u)"`));
|
||||
} else {
|
||||
console.log(chalk.red('请提供选项 -s 或 -u'));
|
||||
}
|
||||
});
|
||||
|
||||
program.addCommand(command);
|
||||
Reference in New Issue
Block a user