From 300562af2d4a6714fe8862e6cadf41797750b42d Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Thu, 25 Jan 2024 14:05:42 +0100 Subject: [PATCH] Update README --- README.md | 22 +++++++++++++++------- src/lib/project/flags.ts | 19 ++++++++++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fd7a73c4..e3f2feeb 100644 --- a/README.md +++ b/README.md @@ -1784,12 +1784,13 @@ Set context values for the current project, org or server ``` USAGE - $ mw context set [--project-id ] [--server-id ] [--org-id ] + $ mw context set [--project-id ] [--server-id ] [--org-id ] [--installation-id ] FLAGS - --org-id= ID or short ID of an organization - --project-id= ID or short ID of a project - --server-id= ID or short ID of a server + --installation-id= ID or short ID of an app installation + --org-id= ID or short ID of an organization + --project-id= ID or short ID of a project + --server-id= ID or short ID of a server DESCRIPTION Set context values for the current project, org or server @@ -1936,12 +1937,14 @@ Create a new cron job ``` USAGE - $ mw cronjob create --description --interval [-i ] [-q] [--disable] [--email ] - [--url | --command ] [--interpreter ] + $ mw cronjob create --description --interval [-p ] [-i ] [-q] [--disable] [--email + ] [--url | --command ] [--interpreter ] FLAGS -i, --installation-id= ID or short ID of an app installation; this flag is optional if a default app installation is set in the context + -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the + context -q, --quiet suppress process output and only display a machine-readable summary. --command= Command to execute for the cron job; either this or `--url` is required. --description= (required) Description of the cron job @@ -1956,10 +1959,15 @@ FLAG DESCRIPTIONS ID or short ID of an app installation; this flag is optional if a default app installation is set in the context - May contain a short ID or a full ID of an app installation; you can also use the "mw context set + May contain a short ID or a full ID of an app installation.; you can also use the "mw context set --installation-id=" command to persistently set a default app installation for all commands that accept this flag. + -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context + + May contain a short ID or a full ID of a project; you can also use the "mw context set --project-id=" command + to persistently set a default project for all commands that accept this flag. + -q, --quiet suppress process output and only display a machine-readable summary. This flag controls if you want to see the process output or only a summary. When using mw non-interactively (e.g. in diff --git a/src/lib/project/flags.ts b/src/lib/project/flags.ts index 06173175..8eaedb60 100644 --- a/src/lib/project/flags.ts +++ b/src/lib/project/flags.ts @@ -43,6 +43,7 @@ export function makeProjectFlagSet( displayName = name, supportsContext = false, } = opts; + const article = displayName.match(/^[aeiou]/i) ? "an" : "a"; const flagName: ContextKey = `${name}-id`; const flags = { @@ -50,19 +51,31 @@ export function makeProjectFlagSet( [flagName]: Flags.string({ char, required: !supportsContext, - summary: `ID or ${shortIDName} of a ${displayName}`, - description: `May contain a ${shortIDName} or a full ID of a ${displayName}.`, + summary: `ID or ${shortIDName} of ${article} ${displayName}`, + description: `May contain a ${shortIDName} or a full ID of ${article} ${displayName}.`, default: undefined, }), } as ContextFlags; const args = { [flagName]: Args.string({ - description: `ID or ${shortIDName} of a ${displayName}`, + description: `ID or ${shortIDName} of ${article} ${displayName}`, required: !supportsContext, }), } as ContextArgs; + if (supportsContext) { + flags[ + flagName + ].summary += `; this flag is optional if a default ${displayName} is set in the context`; + flags[ + flagName + ].description += `; you can also use the "<%= config.bin %> context set --${flagName}=" command to persistently set a default ${displayName} for all commands that accept this flag.`; + args[ + flagName + ].description += `; this argument is optional if a default ${displayName} is set in the context`; + } + const idFromArgsOrFlag = ( flags: FlagOutput, args: ArgOutput,