import { useState } from 'react'
import { Copy, Check } from 'lucide-react'
interface Command {
comment?: string
cmd: string
}
interface Props {
commands: Command[]
}
export function CliCommands({ commands }: Props) {
return (
{commands.map(({ comment, cmd }, i) => (
{comment &&
{comment}
}
{i < commands.length - 1 &&
}
))}
)
}
function CliCommandLine({ cmd }: { cmd: string }) {
const [copied, setCopied] = useState(false)
async function handleCopy() {
try {
await navigator.clipboard.writeText(cmd)
setCopied(true)
window.setTimeout(() => setCopied(false), 1500)
} catch {
// clipboard may be unavailable in tests
}
}
return (
{cmd}
)
}
export function ingestYearCommands(year: number): Command[] {
return [
{ comment: '# Discover season meetings and sessions', cmd: `box-box --ingest-year ${year}` },
{ comment: '# Preview season discovery only', cmd: `box-box --ingest-year ${year} --dry-run` },
]
}
export function ingestMeetingCommands(meetingKey: number): Command[] {
return [
{ comment: '# Full weekend ingest (all sessions)', cmd: `box-box --ingest-meeting ${meetingKey}` },
{ comment: '# Preview without downloading', cmd: `box-box --ingest-meeting ${meetingKey} --dry-run` },
]
}
export function ingestSessionCommands(sessionKey: number): Command[] {
return [{ comment: '# Race Hub datasets for one session', cmd: `box-box --ingest-session ${sessionKey}` }]
}