diff --git a/packages/cli/src/commands/search.tsx b/packages/cli/src/commands/search.tsx new file mode 100644 index 0000000..b26e786 --- /dev/null +++ b/packages/cli/src/commands/search.tsx @@ -0,0 +1,24 @@ +import {Command} from '@oclif/core' +import {render} from 'ink' +import {SearchBox} from '../components/SearchBox.js' +import {getAvailableComponentNames, getRegistry} from '../helpers/registry.js' +import React from 'react' + +export default class Search extends Command { + static override description = 'Search components.' + + static override examples = ['<%= config.bin %> <%= command.id %>'] + + static override flags = {} + + public async run(): Promise { + const registryResult = await getRegistry() + if (!registryResult.ok) { + this.error(registryResult.message) + } + const registry = registryResult.registry + const componentNames = await getAvailableComponentNames(registry) + + render() + } +} diff --git a/packages/cli/src/components/SearchBox.tsx b/packages/cli/src/components/SearchBox.tsx index 61b5c20..049d009 100644 --- a/packages/cli/src/components/SearchBox.tsx +++ b/packages/cli/src/components/SearchBox.tsx @@ -5,7 +5,7 @@ import {Divider} from './Divider.js' import Spinner from 'ink-spinner' import {Box, Text} from 'ink' -export function SearchBox({components}: {components: string[]}) { +export function SearchBox({components, helper}: {components: string[]; helper: string}) { const [query, setQuery] = useState('') const [isLoading, setLoading] = useState(false) const [suggestions, setSuggestions] = useState([]) @@ -20,7 +20,8 @@ export function SearchBox({components}: {components: string[]}) { return ( - + {helper} + ?