How to use @oclif/color - 4 common examples

To help you get started, we’ve selected a few @oclif/color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SakkuCloud / sakku-cli / src / commands / login.ts View on Github external
await writeToken(this, { token: data.result });    // write the access token in the file
        let value = await authService.overview(this);      // sends request the get the user's config
        let overview = JSON.stringify(value.data.result);
        await writeOverview(this, overview)                // write the user's config to the file
        console.log(color.green(messages.loggedin));
      }
      catch (e) {
        common.logError(e);
      }
    }
    else { // login with browser
      try {
        await opn(`${auth_url}${code}`, { wait: false });
      }
      catch (e) {
        cli.url(`${color.green(messages.click_here_to_login_msg)}`, `${auth_url}${code}`);
      }
      cli.action.start(messages.tryToLog);
      await cli.wait(waitTime);
      let isLoggedin = false;
      let repeatedCount = 0;

      while (!isLoggedin) {
        await cli.wait(waitTime);
        try {
          let resp = await authService.authenticate(code);
          console.log(resp);
          await writeToken(this, { token: resp.data.result });
          isLoggedin = true;
        }
        catch (e) {
          if (repeatedCount > maxRepeat) {
github SakkuCloud / sakku-cli / src / commands / login.ts View on Github external
// Project Modules
import { authService } from '../_service/auth.service';
import { messages } from '../consts/msg';
import { auth_url } from '../consts/urls';
import makeId from '../utils/make-id';
import { writeOverview, writeToken } from '../utils/writer';
import { common } from '../utils/common';

export default class Login extends Command {
  static description = 'Login to Sakku cli interface.';

  static examples = [
    `$ sakku login
? there are two ways you can login: (Use arrow keys)
${color.cyan('❯ Login by Username & Password')}
  Login by Browser`
  ];

  static flags = {
    help: flags.help({ char: 'h' })
  };

  async run() {
    let user: { username: string, password: string } = { username: '', password: '' };

    const question = {
      name: 'way',
      message: 'There are two ways you can login:',
      type: 'list',
      choices: [{ name: 'Login by Username & Password' }, { name: 'Login by Browser' }]
    };
github SakkuCloud / sakku-cli / src / commands / login.ts View on Github external
cli.action.start(messages.tryToLog);
      await cli.wait(waitTime);
      let isLoggedin = false;
      let repeatedCount = 0;

      while (!isLoggedin) {
        await cli.wait(waitTime);
        try {
          let resp = await authService.authenticate(code);
          console.log(resp);
          await writeToken(this, { token: resp.data.result });
          isLoggedin = true;
        }
        catch (e) {
          if (repeatedCount > maxRepeat) {
            console.log(color.red(messages.problem_in_login_msg));
            break;
          }
          repeatedCount++;
        }
      }

      if (isLoggedin) {
        try {
          let value = await authService.overview(this);
          let overview = JSON.stringify(value.data.result);
          writeOverview(this, overview);
        }
        catch (e) {
          common.logError(e);
        }
        cli.action.stop(messages.done_msg);
github SakkuCloud / sakku-cli / src / commands / login.ts View on Github external
}
          repeatedCount++;
        }
      }

      if (isLoggedin) {
        try {
          let value = await authService.overview(this);
          let overview = JSON.stringify(value.data.result);
          writeOverview(this, overview);
        }
        catch (e) {
          common.logError(e);
        }
        cli.action.stop(messages.done_msg);
        console.log(color.green(messages.loggedin));
      }
      else {
        cli.action.stop(messages.abort_msg);
      }
    }
  }
}

@oclif/color

@oclif/color ============

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis