-
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
env 无法传递参数 #128
Comments
你好,感谢你提交这个问题。看起来这是一个与 shebang 传递参数相关的问题。你可以尝试以下解决方案:
请尝试这些方法,看看是否能解决你的问题。如果问题仍然存在,请告诉我们。 From Maige. How's my driving? |
Welcome to GitAuto! 🎉
@AhJi26, You have 5 requests left in this cycle which refreshes on 2024-10-06 01:47:00+00:00. |
你好,感谢你反馈这个问题。 你提到的 shebang 无法传递参数的问题已经记录在 Issue #128 中。这个问题可能是由于 目前有两个临时解决方案:
我们会尽快调查并修复这个问题。如果你有进一步的建议或需要更多帮助,请随时 @ 我。 感谢你的耐心等待。 |
@AhJi26 你好!我是一个可以帮助你解决bug、回答问题并成为贡献者的机器人。在等待人类维护者的期间,我可以为你提供帮助。 我发现了一个类似的已关闭问题:使用报错,该问题通过一个 pull request 解决:fix: ignore punycode module is deprecated warning in node 22 [1]。 要解决 #!/usr/bin/env -S node --no-deprecation 这样可以使用 #!/usr/bin/env -S node --no-deprecation
const { Command } = require('commander');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const config = require('../lib/config');
const { searchList } = require('../lib/searchHistory');
updateNotifier({ pkg }).notify();
const program = new Command();
program
.name(pkg.name)
.description(pkg.description)
.version(pkg.version)
.action(() => {
// 如果输入是 "fanyi",没有参数,则忽略
if (process.argv.length > 2) {
return runFY();
}
});
program
.command('config')
.description('设置全局选项')
.addCommand(
new Command('list').description('查看配置项').action(async () => {
const options = await config.load();
console.log(`${chalk.gray(config.getConfigPath())}`);
console.log();
for (const [key, value] of Object.entries(options)) {
console.log(`${chalk.cyan(key)}: ${chalk.yellow(value)}`);
}
}),
)
.addCommand(
new Command('set')
.description('设置配置项')
.argument('<key>', '配置项键名')
.argument('<value>', '配置项值')
.action(async (key, value) => {
const options = {};
if (key === 'GROQ_API_KEY') {
options[key] = value;
} else {
options[key] = value === 'true' ? true : value === 'false' ? false : value;
}
await config.write(options);
}),
);
program
.command('list')
.option('-d, --someDay <char>', '查看指定某天的查询记录')
.option('-r, --recentDays [number]', '查看最近几天内的数据', 0)
.option('-all --show-file [boolean]', '查看全部数据,即单词存放的位置', false)
.action((args) => {
searchList(args);
});
program.on('--help', () => {
console.log('');
console.log(chalk.gray('示例:'));
console.log(`${chalk.cyan(' $ ')}fanyi word`);
console.log(`${chalk.cyan(' $ ')}fanyi world peace`);
console.log(`${chalk.cyan(' $ ')}fanyi chinglish`);
console.log(`${chalk.cyan(' $ ')}fanyi config set color true`);
console.log(`${chalk.cyan(' $ ')}fanyi config set iciba true`);
console.log(`${chalk.cyan(' $ ')}fanyi config set groq true`);
console.log(`${chalk.cyan(' $ ')}fanyi config set GROQ_API_KEY your_api_key_here`);
console.log(`${chalk.cyan(' $ ')}fanyi config list`);
console.log('');
});
program.parse(process.argv);
if (!process.argv.slice(2).length) {
program.help();
}
async function runFY(options = {}) {
const defaultOptions = await config.load();
const mergedOptions = { ...defaultOptions, ...options };
const fanyi = require('..');
fanyi(program.args.join(' '), mergedOptions);
} 这样可以禁用弃用警告并确保参数正确传递 [2]。 |
已提pr #129 |
Sorry, we have an error. Please try again. Have feedback or need help? |
作者你好,我更新了最新版本的fy后遇到了shebang无法传递参数的问题,输出如下
我修改了/usr/lib/node_modules/fanyi/bin/fanyi.js的shebang,去除了--no-deprecation参数,可以正常运行但每次都会输出模块弃用warning导致排版混乱。
似乎shebang中的env无法传递正确传递参数,或许可以修改为其他传递参数的方式或者禁用warning?
平台:archlinux, linux 6.10.10,node 22.9.0
The text was updated successfully, but these errors were encountered: