toes/src/cli/index.ts
Chris Wanstrath 0a7c2b0f1f Add CLI build and install to deploy, handle SSH login shell commands
The deploy script now builds the CLI binary and copies it to /usr/local/bin.
SSH passes commands as `toes -c "command args"`, so parse that form
before falling through to the interactive shell or normal arg handling.
2026-03-16 16:14:31 -07:00

20 lines
573 B
TypeScript
Executable File

#!/usr/bin/env bun
import { program } from './setup'
const isCliUser = process.env.USER === 'cli'
const noArgs = process.argv.length <= 2
const isTTY = !!process.stdin.isTTY
// SSH login shell passes commands as: toes -c "command args"
const shellExec = process.argv[1] === '-c' ? process.argv.slice(2).join(' ') : null
if (shellExec) {
const tokens = shellExec.split(/\s+/).filter(Boolean)
program.parse(['node', 'toes', ...tokens])
} else if (isCliUser && noArgs && isTTY) {
const { shell } = await import('./shell')
await shell()
} else {
program.parse()
}