Skip to content

Commit

Permalink
updated proxyTypeOption to be mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Frederick committed Jan 22, 2024
1 parent 9c5cdf2 commit 767f972
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions cli/src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ export const noInputOption = new Option('--no-input', 'Do not prompt for input')
// Crypto
export const ecdsaOption = new Option('--ecdsa', 'Use ECDSA signature instead of mnemonic');

export const ProxyTypes = ['All', 'Staking', 'NonTransfer'];
export const proxyTypeOption = new Option('--type [type]', 'The type of proxy')
.choices(ProxyTypes)
.makeOptionMandatory();

export const proxyOption = new Option('-p, --proxy <proxy addr>', 'The proxy address to use for this call').argParser(
parseSubstrateAddress,
);

export const proxyTypeOption = new Option('--type [type]', 'The type of proxy');
export const ProxyTypes = ['All', 'Staking', 'NonTransfer'];
// Clone to avoid making this mandatory everywhere
export const mandatoryProxyOption = { ...proxyOption } as Option;
mandatoryProxyOption.makeOptionMandatory();

export const delayOption = new Option(
'--delay [delay]',
Expand Down
10 changes: 5 additions & 5 deletions cli/src/commands/proxy/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from 'commander';
import { proxyOption, ProxyTypes, proxyTypeOption, delayOption } from '../options';
import { mandatoryProxyOption, proxyTypeOption, delayOption } from '../options';
import { setProxyAction, viewProxyAction, removeProxyAction } from './actions';

export function makeProxyCommands() {
Expand All @@ -13,8 +13,8 @@ export function makeProxyCommands() {
export function makeAddProxyCmd() {
return new Command('add')
.description('Set the proxy')
.addOption(proxyOption.makeOptionMandatory())
.addOption(proxyTypeOption.choices(ProxyTypes).makeOptionMandatory())
.addOption(mandatoryProxyOption)
.addOption(proxyTypeOption)
.addOption(delayOption)
.action(setProxyAction);
}
Expand All @@ -26,8 +26,8 @@ export function makeListProxyCmd() {
export function makeRemoveProxyCmd() {
return new Command('remove')
.description('Remove the current proxy')
.addOption(proxyOption.makeOptionMandatory())
.addOption(proxyTypeOption.choices(ProxyTypes).makeOptionMandatory())
.addOption(mandatoryProxyOption)
.addOption(proxyTypeOption)
.addOption(delayOption)
.action(removeProxyAction);
}

0 comments on commit 767f972

Please sign in to comment.