From 040a6e58e3243ec7f13984e0e648a428518fbaa4 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 26 Feb 2024 16:33:51 -0800 Subject: [PATCH] refactor(cli): Consolidate common name flag --- packages/cli/src/endo.js | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/endo.js b/packages/cli/src/endo.js index c736613104..51248e0450 100644 --- a/packages/cli/src/endo.js +++ b/packages/cli/src/endo.js @@ -19,6 +19,10 @@ const packageDescriptorPath = url.fileURLToPath( const commonOptions = { as: ['-a,--as ', 'Pose as named party (as named by current party)'], + name: [ + '-n,--name ', + 'Assigns a name to the result for future reference', + ], }; const parseOptionAsMapping = (optionValueString, obj) => { @@ -121,10 +125,7 @@ export const main = async rawArgs => { .option('--UNCONFINED ', 'Path to a Node.js module') .option(...commonOptions.as) .option('-p,--powers ', 'Name of powers to grant or NONE, SELF, ENDO') - .option( - '-n,--name ', - 'Assigns a name to the result for future reference, persisted between restarts', - ) + .option(...commonOptions.name) .option( '-w,--worker ', 'Reuse an existing worker rather than create a new one', @@ -169,10 +170,7 @@ export const main = async rawArgs => { 'Send the request to another party (default: HOST)', ) .option(...commonOptions.as) - .option( - '-n,--name ', - 'Assigns a name to the result for future reference, persisted between restarts', - ) + .option(...commonOptions.name) .action(async (description, cmd) => { const { name: resultName, @@ -223,10 +221,7 @@ export const main = async rawArgs => { program .command('adopt ') - .option( - '-n,--name ', - 'Name to use, if different than the suggested name.', - ) + .option(...commonOptions.name) .option(...commonOptions.as) .description('adopt a @value from a message') .action(async (messageNumberText, edgeName, cmd) => { @@ -318,10 +313,7 @@ export const main = async rawArgs => { .command('store ') .description('stores a blob') .option(...commonOptions.as) - .option( - '-n,--name ', - 'Assigns a pet name to the result for future reference', - ) + .option(...commonOptions.name) .action(async (storablePath, cmd) => { const { name, as: partyNames } = cmd.opts(); const { store } = await import('./commands/store.js'); @@ -340,10 +332,7 @@ export const main = async rawArgs => { '-w,--worker ', 'Reuse an existing worker rather than create a new one', ) - .option( - '-n,--name ', - 'Assigns a name to the result for future reference, persisted between restarts', - ) + .option(...commonOptions.name) .action(async (source, names, cmd) => { const { name: resultName, @@ -374,7 +363,7 @@ export const main = async rawArgs => { .command('bundle ') .description('stores a program') .option(...commonOptions.as) - .option('-n,--name ', 'Store the bundle into Endo') + .option(...commonOptions.name) .option( '--common-dep ', 'Specify common dependency for bundle (eg node builtin package shims)',