From bc39036ef44ef5dc03b70248d9cbe9e52fe951d3 Mon Sep 17 00:00:00 2001 From: Bradley Hilton Date: Tue, 1 Oct 2019 14:55:03 -0500 Subject: [PATCH] Prettify the prompts and waitings --- src/commands/login.ts | 9 +++++---- src/commands/submit.ts | 18 +++--------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/commands/login.ts b/src/commands/login.ts index e6e42d5..018c41b 100644 --- a/src/commands/login.ts +++ b/src/commands/login.ts @@ -18,15 +18,16 @@ export default class Login extends Command { const cloudAuth = new CloudAuth(); const hasToken = await cloudAuth.hasToken(); if (hasToken) { + cli.action.start(chalk.green('verifying') + ' your token...'); await cloudAuth.getToken(); - cli.log(chalk.green('you are already logged in!')); + cli.action.stop(chalk.green('success, you are already logged in!')); } else { try { - cli.log(chalk.green('*') + ' ' + chalk.gray('waiting for authorization...')); + cli.action.start(chalk.green('waiting') + ' for authorization...'); await cloudAuth.executeAuthFlow(); - cli.action.stop('success!'); + cli.action.stop(chalk.green('success!')); } catch (e) { - cli.action.stop('failure to authenticate.'); + cli.action.stop(chalk.red('failed to authenticate.')); return; } } diff --git a/src/commands/submit.ts b/src/commands/submit.ts index decf138..c364eda 100644 --- a/src/commands/submit.ts +++ b/src/commands/submit.ts @@ -64,19 +64,6 @@ export default class Submit extends Command { //#endregion //#region asking for information - /* - const result = await inquirer.prompt([{ - type: 'input', - name: 'email', - message: 'What is the publisher\'s email address?', - validate: (answer: string) => { - const regex = /^[^@\s]+@[^@\s]+\.[^@\s]+$/g; - - return regex.test(answer); - }, - }]); - */ - const cloudAuth = new CloudAuth(); const hasToken = await cloudAuth.hasToken(); let email = ''; @@ -90,10 +77,11 @@ export default class Submit extends Command { if (cloudAccount.hasAccount) { try { - cli.log(chalk.green('*') + ' ' + chalk.gray('waiting for authorization...')); + cli.action.start(chalk.green('*') + ' ' + chalk.gray('waiting for authorization...')); await cloudAuth.executeAuthFlow(); + cli.action.stop(chalk.green('success!')); } catch (e) { - cli.action.stop('failure to authenticate.'); + cli.action.stop(chalk.red('failed to authenticate.')); return; } } else { -- GitLab