index.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env bun
  2. import { install } from "./install"
  3. import type { InstallArgs, BooleanArg } from "./types"
  4. function parseArgs(args: string[]): InstallArgs {
  5. const result: InstallArgs = {
  6. tui: true,
  7. }
  8. for (const arg of args) {
  9. if (arg === "--no-tui") {
  10. result.tui = false
  11. } else if (arg === "--skip-auth") {
  12. result.skipAuth = true
  13. } else if (arg.startsWith("--antigravity=")) {
  14. result.antigravity = arg.split("=")[1] as BooleanArg
  15. } else if (arg.startsWith("--openai=")) {
  16. result.openai = arg.split("=")[1] as BooleanArg
  17. } else if (arg.startsWith("--cerebras=")) {
  18. result.cerebras = arg.split("=")[1] as BooleanArg
  19. } else if (arg.startsWith("--tmux=")) {
  20. result.tmux = arg.split("=")[1] as BooleanArg
  21. } else if (arg === "-h" || arg === "--help") {
  22. printHelp()
  23. process.exit(0)
  24. }
  25. }
  26. return result
  27. }
  28. function printHelp(): void {
  29. console.log(`
  30. oh-my-opencode-slim installer
  31. Usage: bunx oh-my-opencode-slim install [OPTIONS]
  32. Options:
  33. --antigravity=yes|no Antigravity subscription (yes/no)
  34. --openai=yes|no OpenAI API access (yes/no)
  35. --cerebras=yes|no Cerebras API access (yes/no)
  36. --tmux=yes|no Enable tmux integration (yes/no)
  37. --no-tui Non-interactive mode (requires all flags)
  38. --skip-auth Skip authentication reminder
  39. -h, --help Show this help message
  40. Examples:
  41. bunx oh-my-opencode-slim install
  42. bunx oh-my-opencode-slim install --no-tui --antigravity=yes --openai=yes --cerebras=no --tmux=yes
  43. `)
  44. }
  45. async function main(): Promise<void> {
  46. const args = process.argv.slice(2)
  47. if (args.length === 0 || args[0] === "install") {
  48. const installArgs = parseArgs(args.slice(args[0] === "install" ? 1 : 0))
  49. const exitCode = await install(installArgs)
  50. process.exit(exitCode)
  51. } else if (args[0] === "-h" || args[0] === "--help") {
  52. printHelp()
  53. process.exit(0)
  54. } else {
  55. console.error(`Unknown command: ${args[0]}`)
  56. console.error("Run with --help for usage information")
  57. process.exit(1)
  58. }
  59. }
  60. main().catch((err) => {
  61. console.error("Fatal error:", err)
  62. process.exit(1)
  63. })