|
| 1 | +import { CliCommand, CliCommandFlag } from '@/data/cli-commands'; |
| 2 | +import { Heading, Text, Flex, View } from '@aws-amplify/ui-react'; |
| 3 | +import { MDXCode } from '../MDXComponents'; |
| 4 | +import { CommandHeading, SubCommandHeading } from './CommandHeading'; |
| 5 | +import { Fragment } from 'react'; |
| 6 | + |
| 7 | +export function Command({ |
| 8 | + name, |
| 9 | + description, |
| 10 | + usage, |
| 11 | + flags, |
| 12 | + subCommands |
| 13 | +}: CliCommand) { |
| 14 | + return ( |
| 15 | + <Flex className="commands-list__command"> |
| 16 | + <CommandHeading>{name}</CommandHeading> |
| 17 | + <Text>{description}</Text> |
| 18 | + <MDXCode language="terminal" codeString={usage} showLineNumbers={false} /> |
| 19 | + {flags && flags.length > 0 && ( |
| 20 | + <Flex className="commands-list__command__flags"> |
| 21 | + {flags.map((flag: CliCommandFlag) => ( |
| 22 | + <Fragment key={`${name}-${flag.short}`}> |
| 23 | + <code className="commands-list__command__flags__code"> |
| 24 | + {flag.short && <span>-{flag.short}|</span>} |
| 25 | + <span>--{flag.long}</span> |
| 26 | + </code> |
| 27 | + <Text>{flag.description}</Text> |
| 28 | + </Fragment> |
| 29 | + ))} |
| 30 | + </Flex> |
| 31 | + )} |
| 32 | + {subCommands && subCommands.length > 0 && ( |
| 33 | + <Flex className="commands-list__command__subcommands"> |
| 34 | + {subCommands.map((subCommand) => ( |
| 35 | + <Fragment key={`${name}-${subCommand.name}`}> |
| 36 | + <SubCommandHeading parentCommand={name}> |
| 37 | + {subCommand.name} |
| 38 | + </SubCommandHeading> |
| 39 | + <Text>{subCommand.description}</Text> |
| 40 | + <MDXCode |
| 41 | + language="terminal" |
| 42 | + codeString={`amplify ${name} ${subCommand.name}`} |
| 43 | + showLineNumbers={false} |
| 44 | + /> |
| 45 | + </Fragment> |
| 46 | + ))} |
| 47 | + </Flex> |
| 48 | + )} |
| 49 | + </Flex> |
| 50 | + ); |
| 51 | +} |
0 commit comments