From a49b0743ab33761c434d262fbf2694db2092810d Mon Sep 17 00:00:00 2001
From: White-Patrasche <5338095@gmail.com>
Date: Thu, 22 Jun 2023 15:48:18 +0900
Subject: [PATCH] feat: get line from user input
---
source/app.js | 39 ++++++++++++++++++++++++++++++---------
source/cli.js | 28 ++++++++++++++--------------
2 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/source/app.js b/source/app.js
index 6341337..591314e 100644
--- a/source/app.js
+++ b/source/app.js
@@ -1,10 +1,31 @@
import React from 'react';
-import {Text} from 'ink';
-
-export default function App({name = 'Stranger'}) {
- return (
-
- Hello, {name}? nice to meet you.
-
- );
-}
+import { Box, Text } from 'ink';
+import Enquirer from 'enquirer';
+
+const App = () => {
+ const [name, setName] = React.useState();
+
+ React.useEffect(() => {
+ const enquirer = new Enquirer();
+ enquirer
+ .prompt({
+ type: 'input',
+ name: 'username',
+ message: 'What is your name?'
+ })
+ .then(answer => setName(answer.username));
+ }, []);
+
+
+ return name ? (
+
+ Hello, {name}!
+
+ ) : (
+
+ Welcome to our CLI App. Please input your name.
+
+ );
+};
+
+export default App;
\ No newline at end of file
diff --git a/source/cli.js b/source/cli.js
index 7538017..8c6fa26 100644
--- a/source/cli.js
+++ b/source/cli.js
@@ -1,24 +1,24 @@
#!/usr/bin/env node
import React from 'react';
-import {render} from 'ink';
+import { render } from 'ink';
import meow from 'meow';
import App from './app.js';
const cli = meow(
- `
- Usage
- $ up-date-cli
+ `
+ Usage
+ $ up-date
- Options
- --name Your name
+ Options
+ --name Your name
- Examples
- $ up-date-cli --name=Jane
- Hello, Jane
- `,
- {
- importMeta: import.meta,
- },
+ Examples
+ $ up-date --name=Jane
+ Hello, Jane
+ `,
+ {
+ importMeta: import.meta,
+ }
);
-render();
+render();