Skip to content

Commit 1d02865

Browse files
committed
feat: improve login ux
1 parent 7a6f166 commit 1d02865

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/commands/shell.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import readline from 'node:readline';
22
import chalk from 'chalk';
33
import Conf from 'conf';
44
import { execCommand, getPrompt } from '../executor.js';
5-
import { getAuthToken } from './auth.js';
5+
import { getAuthToken, login } from './auth.js';
66
import { PROJECT_NAME } from '../commons.js';
77

88
const config = new Conf({ projectName: PROJECT_NAME });
@@ -24,16 +24,17 @@ export function updatePrompt(currentPath) {
2424
/**
2525
* Start the interactive shell
2626
*/
27-
export function startShell() {
27+
export async function startShell() {
2828
if (!getAuthToken()) {
29-
console.log(chalk.red('Please login first using: puter login'));
30-
process.exit(1);
29+
console.log(chalk.cyan('Please login first (or use CTRL+C to exit):'));
30+
await login();
31+
console.log(chalk.green(`Now just type: ${chalk.cyan('puter')} to begin.`));
32+
process.exit(0);
3133
}
3234

33-
rl.setPrompt(getPrompt());
34-
3535
try {
3636
console.log(chalk.green('Welcome to Puter-CLI! Type "help" for available commands.'));
37+
rl.setPrompt(getPrompt());
3738
rl.prompt();
3839

3940
rl.on('line', async (line) => {

0 commit comments

Comments
 (0)