|
@@ -22,11 +22,17 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
|
|
|
'Name of the draft to create the opening from.',
|
|
|
dependsOn: ['useDraft']
|
|
|
}),
|
|
|
+ createDraftOnly: flags.boolean({
|
|
|
+ char: 'c',
|
|
|
+ description:
|
|
|
+ 'If provided - the extrinsic will not be executed. Use this flag if you only want to create a draft.'
|
|
|
+ }),
|
|
|
skipPrompts: flags.boolean({
|
|
|
char: 's',
|
|
|
description:
|
|
|
"Whether to skip all prompts when adding from draft (will use all default values)",
|
|
|
- dependsOn: ['useDraft']
|
|
|
+ dependsOn: ['useDraft'],
|
|
|
+ exclusive: ['createDraftOnly']
|
|
|
})
|
|
|
};
|
|
|
|
|
@@ -43,20 +49,33 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
|
|
|
defaultValues = await this.loadOpeningDraftParams(draftName);
|
|
|
}
|
|
|
|
|
|
- await this.requestAccountDecoding(account); // Prompt for password
|
|
|
if (!flags.skipPrompts) {
|
|
|
- const params = await this.buildAndSendExtrinsic(
|
|
|
- account,
|
|
|
- apiModuleByGroup[this.group],
|
|
|
- 'addWorkerOpening',
|
|
|
- { 'human_readable_text': { struct: HRTStruct, schemaValidator } },
|
|
|
- defaultValues
|
|
|
- );
|
|
|
+ const module = apiModuleByGroup[this.group];
|
|
|
+ const method = 'addWorkerOpening';
|
|
|
+ const jsonArgsMapping = { 'human_readable_text': { struct: HRTStruct, schemaValidator } };
|
|
|
|
|
|
- const saveDraft = await this.simplePrompt({
|
|
|
- message: 'Do you wish to save this opportunity as draft?',
|
|
|
- type: 'confirm'
|
|
|
- });
|
|
|
+ let saveDraft = false, params: ApiMethodInputArg[];
|
|
|
+ if (flags.createDraftOnly) {
|
|
|
+ params = await this.promptForExtrinsicParams(module, method, jsonArgsMapping, defaultValues);
|
|
|
+ saveDraft = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ await this.requestAccountDecoding(account); // Prompt for password
|
|
|
+
|
|
|
+ params = await this.buildAndSendExtrinsic(
|
|
|
+ account,
|
|
|
+ module,
|
|
|
+ method,
|
|
|
+ jsonArgsMapping,
|
|
|
+ defaultValues,
|
|
|
+ true
|
|
|
+ );
|
|
|
+
|
|
|
+ saveDraft = await this.simplePrompt({
|
|
|
+ message: 'Do you wish to save this opportunity as draft?',
|
|
|
+ type: 'confirm'
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
if (saveDraft) {
|
|
|
const draftName = await this.promptForNewOpeningDraftName();
|
|
@@ -66,6 +85,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ await this.requestAccountDecoding(account); // Prompt for password
|
|
|
this.log(chalk.white('Sending the extrinsic...'));
|
|
|
await this.sendExtrinsic(account, apiModuleByGroup[this.group], 'addWorkerOpening', defaultValues!);
|
|
|
this.log(chalk.green('Opening succesfully created!'));
|