Skip to content

Commit

Permalink
Simplify help function
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Feb 14, 2024
1 parent 524894b commit 5b79861
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Additional options:
export async function deploy(args: string[], deployClient?: DeployClient): Promise<void> {
const { parsedArgs, extraArgs } = parseArgs(args);

if (!help(parsedArgs, extraArgs)) {
if (!help(parsedArgs)) {
const functionArgs = getFunctionArgs(parsedArgs, extraArgs);
const client = deployClient ?? getDeployClient();
const address = await deployContract(functionArgs, client);
Expand All @@ -49,13 +49,13 @@ function parseArgs(args: string[]) {
return { parsedArgs, extraArgs };
}

function help(parsedArgs: minimist.ParsedArgs, extraArgs: string[]): boolean {
if (parsedArgs['help']) {
function help(parsedArgs: minimist.ParsedArgs): boolean {
if (!parsedArgs['help']) {
return false;
} else {
console.log(USAGE);
console.log(DETAILS);
return true;
} else {
return false;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/commands/get-approval-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type Command = 'getDeployApprovalProcess' | 'getUpgradeApprovalProcess';
export async function getApprovalProcess(command: Command, args: string[], deployClient?: DeployClient): Promise<void> {
const { parsedArgs, extraArgs } = parseArgs(args);

if (!help(command, parsedArgs, extraArgs)) {
if (!help(command, parsedArgs)) {
const network = getFunctionArgs(command, parsedArgs, extraArgs);
const client = deployClient ?? getDeployClient();

Expand Down Expand Up @@ -64,8 +64,10 @@ function parseArgs(args: string[]) {
return { parsedArgs, extraArgs };
}

function help(command: Command, parsedArgs: minimist.ParsedArgs, extraArgs: string[]): boolean {
if (parsedArgs['help']) {
function help(command: Command, parsedArgs: minimist.ParsedArgs): boolean {
if (!parsedArgs['help']) {
return false;
} else {
switch (command) {
case 'getDeployApprovalProcess':
console.log(USAGE_DEPLOY);
Expand All @@ -79,8 +81,6 @@ function help(command: Command, parsedArgs: minimist.ParsedArgs, extraArgs: stri
throw new Error(`Unknown command: ${command}`);
}
return true;
} else {
return false;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/commands/propose-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Additional options:
export async function proposeUpgrade(args: string[], deployClient?: DeployClient): Promise<void> {
const { parsedArgs, extraArgs } = parseArgs(args);

if (!help(parsedArgs, extraArgs)) {
if (!help(parsedArgs)) {
const functionArgs = getFunctionArgs(parsedArgs, extraArgs);
const client = deployClient ?? getDeployClient();
const upgradeResponse = await upgradeContract(functionArgs, client);
Expand All @@ -47,13 +47,13 @@ function parseArgs(args: string[]) {
return { parsedArgs, extraArgs };
}

function help(parsedArgs: minimist.ParsedArgs, extraArgs: string[]): boolean {
if (parsedArgs['help']) {
function help(parsedArgs: minimist.ParsedArgs): boolean {
if (!parsedArgs['help']) {
return false;
} else {
console.log(USAGE);
console.log(DETAILS);
return true;
} else {
return false;
}
}

Expand Down

0 comments on commit 5b79861

Please sign in to comment.