fix: fullObject option for send create (#285)

This commit is contained in:
Sang 2021-05-12 05:56:38 +10:00 committed by GitHub
parent 5edd0a2c76
commit 50ee3c0f07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -170,15 +170,23 @@ export class SendProgram extends Program {
.option('--text <text>', 'text to Send. Can also be specified in parent\'s JSON.')
.option('--hidden', 'text hidden flag. Valid only with the --text option.')
.option('--password <password>', 'optional password to access this Send. Can also be specified in JSON')
.option('--fullObject', 'Specifies that the full Send object should be returned rather than just the access url.')
.on('--help', () => {
writeLn('');
writeLn('Note:');
writeLn(' Options specified in JSON take precedence over command options');
writeLn('', true);
})
.action(async (encodedJson: string, options: program.OptionValues) => {
const response = await this.runCreate(encodedJson, options);
.action(async (encodedJson: string, options: program.OptionValues, args: { parent: program.Command }) => {
// Work-around to support `--fullObject` option for `send create --fullObject`
// Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option
// to be defind on both parent-command and sub-command
const { fullObject = false } = args.parent.opts();
const mergedOptions = {
...options,
fullObject
};
const response = await this.runCreate(encodedJson, mergedOptions);
this.processResponse(response);
});
}