Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multiple flags bug #350

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/combine-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
id: create-combined-pr
name: Create Combined PR
with:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"license": "Apache-2.0",
"dependencies": {
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/core": "0.0.56",
"chalk": "^4.1.2",
"iter-tools-es": "^7.5.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-common/src/lib/common-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const composeFlags = {
file: Flags.string({
description: 'Compose configuration file',
multiple: true,
singleValue: true,
required: false,
char: 'f',
default: [],
Expand All @@ -20,6 +21,7 @@ export const composeFlags = {
'system-compose-file': Flags.string({
description: 'Add extra Compose configuration file without overriding the defaults',
multiple: true,
singleValue: true,
required: false,
default: [],
helpGroup: 'GLOBAL',
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"dependencies": {
"@inquirer/confirm": "^2.0.14",
"@oclif/core": "^2",
"@oclif/core": "^3",
"@oclif/plugin-help": "^5",
"@preevy/cli-common": "0.0.56",
"@preevy/common": "0.0.56",
Expand All @@ -38,7 +38,6 @@
"yaml": "^2.3.2"
},
"devDependencies": {
"@oclif/test": "^2.3.4",
"@types/inquirer": "^8.0.0",
"@types/inquirer-autocomplete-prompt": "^3.0.3",
"@types/lodash": "^4.14.192",
Expand All @@ -55,7 +54,7 @@
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"jest": "29.7.0",
"oclif": "^3",
"oclif": "^4.0.4",
"pkg": "^5.8.1",
"shx": "^0.3.3",
"ts-node": "^10.9.1",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/profile/config/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class UpdateProfileConfig extends ProfileCommand<typeof UpdatePro
description: 'Unset a configuration option',
default: [],
multiple: true,
singleValue: true,
}),
}

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/purge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class Purge extends DriverCommand<typeof Purge> {
description: 'Resource type(s) to delete',
default: [machineResourceType],
multiple: true,
singleValue: true,
}),
force: Flags.boolean({
description: 'Do not ask for confirmation',
Expand Down
19 changes: 4 additions & 15 deletions packages/cli/src/help.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CommandHelp as BaseCommandHelp, Help as OclifHelp } from '@oclif/core'
import { CommandHelp as BaseCommandHelp, Command, Help as OclifHelp } from '@oclif/core'
import { HelpOptions, Config, Topic } from '@oclif/core/lib/interfaces'
import { BaseCommand, text } from '@preevy/cli-common'

class GlobalFlagsHelp extends BaseCommandHelp {
constructor(config: Config, opts: HelpOptions) {
super(BaseCommand, config, opts)
constructor(command: Command.Loadable, config: Config, opts: HelpOptions) {
super(command, config, opts)
}

globalFlags() {
Expand All @@ -13,20 +13,9 @@ class GlobalFlagsHelp extends BaseCommandHelp {
}
}

class CommandHelp extends BaseCommandHelp {
constructor(...args: ConstructorParameters<typeof BaseCommandHelp>) {
super(...args)
}
}

export default class Help extends OclifHelp {
constructor(...args: ConstructorParameters<typeof OclifHelp>) {
super(...args)
this.CommandHelpClass = CommandHelp
}

protected formatGlobalFlags(): string {
return this.section('GLOBAL FLAGS', new GlobalFlagsHelp(this.config, this.opts).globalFlags())
return this.section('GLOBAL FLAGS', new GlobalFlagsHelp(this.config.commands[0], this.config, this.opts).globalFlags())
}

override async showRootHelp(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver-azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@azure/arm-subscriptions": "^5.1.0",
"@azure/identity": "^3.2.2",
"@azure/logger": "^1.0.4",
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/core": "0.0.56",
"inquirer": "^8.0.0",
"inquirer-autocomplete-prompt": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver-gce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@google-cloud/compute": "^4.0.1",
"@google-cloud/storage": "^6.9.5",
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/core": "0.0.56",
"google-auth-library": "^8.7.0",
"google-gax": "^4.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver-kube-pod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@kubernetes/client-node": "^0.18.1",
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/common": "0.0.56",
"@preevy/core": "0.0.56",
"fast-safe-stringify": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/driver-lightsail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@aws-sdk/client-s3": "^3.271.0",
"@aws-sdk/client-sts": "^3.289.0",
"@aws-sdk/util-waiter": "^3.271.0",
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/core": "0.0.56",
"inquirer": "^8.0.0",
"inquirer-autocomplete-prompt": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-github-pr-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"license": "Apache-2.0",
"dependencies": {
"@oclif/core": "^2",
"@oclif/core": "^3",
"@preevy/cli-common": "0.0.56",
"@preevy/core": "0.0.56",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LinkGithubPr extends BaseGithubPrCommand<typeof LinkGithubPr> {
const urls = await this.config.runCommand('urls', [
...(this.flags.id === undefined ? [] : [`--id ${this.flags.id}`]),
...(this.flags.debug === undefined ? [] : ['--debug']),
...(this.flags.file.map(f => `--file ${f}`)),
...Array.isArray(this.flags.file) ? (this.flags.file.map(f => `--file ${f}`)) : [],
...(this.flags.project === undefined ? [] : [`--project ${this.flags.project}`]),
'--json',
]) as FlatTunnel[]
Expand Down
25 changes: 25 additions & 0 deletions patches/@oclif+core+3.12.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/node_modules/@oclif/core/lib/interfaces/parser.d.ts b/node_modules/@oclif/core/lib/interfaces/parser.d.ts
index acb8583..2d53745 100644
--- a/node_modules/@oclif/core/lib/interfaces/parser.d.ts
+++ b/node_modules/@oclif/core/lib/interfaces/parser.d.ts
@@ -200,6 +200,7 @@ export type OptionFlagProps = FlagProps & {
helpValue?: string;
options?: readonly string[];
multiple?: boolean;
+ singleValue?: boolean;
/**
* Delimiter to separate the values for a multiple value flag.
* Only respected if multiple is set to true. Default behavior is to
diff --git a/node_modules/@oclif/core/lib/parser/parse.js b/node_modules/@oclif/core/lib/parser/parse.js
index 032063d..72d2ed5 100644
--- a/node_modules/@oclif/core/lib/parser/parse.js
+++ b/node_modules/@oclif/core/lib/parser/parse.js
@@ -145,7 +145,7 @@ class Parser {
continue;
}
}
- if (parsingFlags && this.currentFlag && this.currentFlag.multiple) {
+ if (parsingFlags && this.currentFlag && this.currentFlag.multiple && !this.currentFlag.singleValue) {
this.raw.push({ flag: this.currentFlag.name, input, type: 'flag' });
continue;
}
Loading
Loading