fmode-image.mjs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env node
  2. import { fileURLToPath } from 'node:url';
  3. import { dirname, join } from 'node:path';
  4. import { spawn } from 'node:child_process';
  5. const __dirname = dirname(fileURLToPath(import.meta.url));
  6. const libPath = join(__dirname, '..', 'lib', 'fmode-image.mjs');
  7. const args = process.argv.slice(2);
  8. if (!args.length || args[0] === '--help' || args[0] === '-h') {
  9. const { MODES } = await import(libPath);
  10. console.log(`
  11. fmode-image v2.0 — AI架构图和场景插图生成器
  12. 用法:
  13. npx fmode-image --arch "prompt" [name] 架构图 ¥0.5
  14. npx fmode-image --app "prompt" [name] 应用界面 ¥0.5
  15. npx fmode-image --scene "prompt" [name] 场景插图 ¥0.3
  16. npx fmode-image --slide "prompt" [name] 整页PPT ¥0.5
  17. npx fmode-image --explode "prompt" [name] 爆炸图 ¥0.5
  18. npx fmode-image --detail "prompt" [name] 细节图 ¥0.3
  19. 可用模式:`);
  20. for (const [m, c] of Object.entries(MODES)) {
  21. console.log(` ${m.padEnd(12)} ${c.size.padEnd(14)} ¥${c.cost.toFixed(1)} ${c.desc}`);
  22. }
  23. console.log(`\n环境变量: FMODE_API_KEY(必设), SKILL_IMAGE_OUTPUT(默认当前目录)`);
  24. process.exit(0);
  25. }
  26. const child = spawn(process.execPath, [libPath, ...args], { stdio: 'inherit', shell: false });
  27. child.on('exit', (code) => process.exit(code ?? 0));