From 50ee3c0f078e03d64b9141014cacb0ac0cb99e75 Mon Sep 17 00:00:00 2001 From: Sang <11912225+hantatsang@users.noreply.github.com> Date: Wed, 12 May 2021 05:56:38 +1000 Subject: [PATCH] fix: fullObject option for send create (#285) --- src/send.program.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/send.program.ts b/src/send.program.ts index 6a77135c8b..c4fe73dacf 100644 --- a/src/send.program.ts +++ b/src/send.program.ts @@ -170,15 +170,23 @@ export class SendProgram extends Program { .option('--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 ', '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); }); }