Skip to content
Snippets Groups Projects
Commit 60b0aaa0 authored by michael.minelli's avatar michael.minelli
Browse files

Sesssion => gilab: move token from param to option

parent f582a479
No related branches found
No related tags found
No related merge requests found
Pipeline #26546 passed
import chalk from 'chalk'; import chalk from 'chalk';
import CommanderCommand from '../../CommanderCommand'; import CommanderCommand from '../../CommanderCommand';
import GitlabManager from '../../../managers/GitlabManager'; import GitlabManager from '../../../managers/GitlabManager';
import inquirer from 'inquirer';
class SessionGitlabLoginCommand extends CommanderCommand { class SessionGitlabLoginCommand extends CommanderCommand {
...@@ -9,14 +10,23 @@ class SessionGitlabLoginCommand extends CommanderCommand { ...@@ -9,14 +10,23 @@ class SessionGitlabLoginCommand extends CommanderCommand {
protected defineCommand() { protected defineCommand() {
this.command this.command
.description('register the gitlab token') .description('register the gitlab token')
.argument('<token>', 'personal access token from GitLab with api scope') .option('-t, --token <string>', 'personal access token from GitLab with api scope')
.action(this.commandAction.bind(this)); .action(this.commandAction.bind(this));
} }
protected async commandAction(token: string): Promise<void> { protected async commandAction(options: any): Promise<void> {
if ( !options.token ) {
options.token = (await inquirer.prompt({
type : 'password',
name : 'token',
message: 'Please enter your gitlab token',
mask : ''
})).token;
}
console.log(chalk.cyan('Please wait while we are testing your Gitlab token...')); console.log(chalk.cyan('Please wait while we are testing your Gitlab token...'));
GitlabManager.login(token); GitlabManager.login(options.token);
await GitlabManager.testToken(); await GitlabManager.testToken();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment