11import React , { useEffect , useState } from 'react' ;
2- import { Text } from 'ink' ;
32import { Result } from 'meow' ;
4- import { commandsManual } from './manual.js' ;
5- import Login from './components/login.js' ;
6- import { Flags } from './flags.js' ;
3+ import Login from './components/commands/login.js' ;
4+ import { Flags } from './lib/cli-flags.js' ;
5+ import Publish from './components/commands/publish.js' ;
6+ import Help from './components/commands/help.js' ;
7+ import Chat from './components/commands/chat.js' ;
8+ import Logout from './components/commands/logout.js' ;
79
810export default function App ( { cli} : { cli : Result < Flags > } ) {
911 const [ command , setCommand ] = useState < string | undefined > ( undefined ) ;
@@ -13,35 +15,13 @@ export default function App({cli}: {cli: Result<Flags>}) {
1315 setCommand ( cmd ) ;
1416 } , [ cli . input ] ) ;
1517
16- if ( ! command ) return null ;
17- else if ( command === 'help' ) {
18- const subCommand = cli . input [ 1 ] ;
19- if ( ! subCommand ) {
20- return < Text > { cli . help } </ Text > ;
21- } else {
22- return < Text > { commandsManual [ subCommand ] } </ Text > ;
23- }
24- } else if ( command === 'chat' ) {
25- const message = cli . input [ 1 ] ;
26- return (
27- < >
28- < Text >
29- Hello, < Text color = "green" > { message } </ Text >
30- </ Text >
31- </ >
32- ) ;
33- } else if ( command === 'login' ) {
34- return < Login cli = { cli } /> ;
35- } else if ( command === 'logout' ) {
36- return < Text > Logout from the Pulse Editor Platform</ Text > ;
37- } else if ( command === 'publish' ) {
38- return (
39- < Text >
40- Publish Pulse Editor Extension in current directory to the Pulse Editor
41- Platform
42- </ Text >
43- ) ;
44- }
45-
46- return < Text > { cli . help } </ Text > ;
18+ return (
19+ < >
20+ { command === 'help' && < Help cli = { cli } /> }
21+ { command === 'chat' && < Chat cli = { cli } /> }
22+ { command === 'login' && < Login cli = { cli } /> }
23+ { command === 'logout' && < Logout cli = { cli } /> }
24+ { command === 'publish' && < Publish cli = { cli } /> }
25+ </ >
26+ ) ;
4727}
0 commit comments