-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ddimitrioglo/issue_9
#AWSAML Major refactoring (w/ breaking changes)
- Loading branch information
Showing
17 changed files
with
602 additions
and
290 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const rlex = require('../src/extra-readline'); | ||
const Command = require('../src/command'); | ||
|
||
class AliasCommand extends Command { | ||
/** | ||
* @return {Promise} | ||
*/ | ||
run() { | ||
const config = this.getConfig(); | ||
const aliases = this.getConfig('aliases'); | ||
const isDelete = this.getOption('delete', 'd', false); | ||
const accountId = this.getOption('account', 'a', false); | ||
|
||
if (!accountId || accountId.constructor === Boolean) { | ||
return Promise.reject('Account ID is required'); | ||
} | ||
|
||
if (isDelete) { | ||
delete aliases[accountId]; | ||
this.updateConfig(config); | ||
|
||
return Promise.resolve('Done!'); | ||
} | ||
|
||
return rlex.promiseQuestion(`Alias for account ${accountId} (${aliases[accountId] || accountId}): `).then(answer => { | ||
if (answer) { | ||
aliases[accountId] = answer; | ||
} | ||
|
||
return Promise.resolve(); | ||
}).then(() => { | ||
this.updateConfig(config); | ||
|
||
return Promise.resolve('Done!'); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = AliasCommand; |
Oops, something went wrong.