import ReactMarkdown from 'react-markdown' import { CodeBlock, IconChevronRight, Tabs } from 'ui' import spec from '~/spec/cli_v1_commands.yaml' assert { type: 'yml' } import Options from '~/components/Options' import Param from '~/components/Params' import RefSubLayout from '~/layouts/ref/RefSubLayout' import RefDetailCollapse from './RefDetailCollapse' export type Flag = { id: string name: string description: string default_value: string accepted_values: AcceptedValue[] required?: boolean /** Whether subcommands inherit this flag. */ inherit?: boolean } export type AcceptedValue = { id: string name: string type: 'string' | 'boolean' | 'object' description?: string } export type Example = { id: string name: string code: string response: string description?: string } export type Command = { id: string title: string description: string flags?: Flag[] summary: string tags?: string[] links?: string[] subcommands?: string[] usage?: string examples?: Example[] } const CliCommandSection = (props) => { const command = spec.commands.find((x: any) => x.id === props.funcData.id) const parentCommand = spec.commands.find( (x: any) => x.subcommands && x.subcommands.find((y: any) => y === props.funcData.id) ) const commandFlags = [ ...(parentCommand?.flags?.filter((x: any) => x.inherit) || []), ...command.flags, ] return (
{command.description ? (
{command.description}
) : (

{command.summary}

)}
{command.subcommands?.length > 0 && (

Available Commands

)} {commandFlags.length > 0 && ( <>

Flags

    {commandFlags.map((flag: Flag) => ( <>
  • {flag?.accepted_values && ( {flag?.accepted_values.map((value) => { return })} )}
  • ))}
)}
{(command.examples || command.usage) && (
{command.examples ? ( command.examples.map((example) => { const exampleId = `${command.id}-${example.id}` return ( {example.code} {example.response} {example.description && (
{example.description}
)}
) }) ) : ( // TODO: remove this block once all commands have examples {command.usage} )}
)}
) } export default CliCommandSection