Skip to content

Commit

Permalink
chore: make add options to multiple commands more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Jul 18, 2024
1 parent 0e6ae14 commit 9c8cbda
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sui/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ const addExtendedOptions = (program, options = {}) => {
return program;
};

const addBaseOptionsToCommands = (program, options = {}) => {
// `optionMethod` is a method such as `addBaseOptions`
// `options` is an option object for optionMethod
const addOptionsToCommands = (program, optionMethod, options) => {
if (program.commands.length > 0) {
program.commands.forEach((command) => {
addBaseOptions(command, options);
optionMethod(command, options);
});
}

optionMethod(program, options);
};

module.exports = {
addBaseOptions,
addExtendedOptions,
addBaseOptionsToCommands,
addOptionsToCommands,
};

0 comments on commit 9c8cbda

Please sign in to comment.