diff --git a/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts b/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts index 33ffe4713dbce6bf01101a2314a03dc8d8d6edae..f7b156ad0bd2981fcfc082023fd80b029624c6b1 100644 --- a/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts +++ b/NodeApp/src/commander/session/Gitlab/SessionGitlabLoginCommand.ts @@ -1,6 +1,7 @@ import chalk from 'chalk'; import CommanderCommand from '../../CommanderCommand'; import GitlabManager from '../../../managers/GitlabManager'; +import inquirer from 'inquirer'; class SessionGitlabLoginCommand extends CommanderCommand { @@ -9,14 +10,23 @@ class SessionGitlabLoginCommand extends CommanderCommand { protected defineCommand() { this.command .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)); } - 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...')); - GitlabManager.login(token); + GitlabManager.login(options.token); await GitlabManager.testToken(); }