Skip to content

Commit 909e207

Browse files
committed
fix: remove dead code
1 parent 7f7fe9b commit 909e207

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

messages/messages.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ Set varargs with this format: key=value or key="value with spaces"
117117

118118
Found duplicate argument %s.
119119

120-
# warning.arrayInputFormat
121-
122-
The input format for array arguments has changed. Use this format: --array-flag value1 --array-flag value2 --array-flag value3
123-
124120
# flags.flags-dir.summary
125121

126122
Import flag values from a directory.

src/compatibility.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { Flags } from '@oclif/core';
9-
import { Lifecycle, Messages } from '@salesforce/core';
9+
import { Messages } from '@salesforce/core';
1010
import { orgApiVersionFlag } from './flags/orgApiVersion.js';
1111
import { optionalHubFlag, optionalOrgFlag, requiredHubFlag, requiredOrgFlag } from './flags/orgFlags.js';
1212

@@ -98,17 +98,4 @@ export type ArrayWithDeprecationOptions = {
9898
export const arrayWithDeprecation = Flags.custom<string[], ArrayWithDeprecationOptions>({
9999
multiple: true,
100100
delimiter: ',',
101-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
102-
// @ts-expect-error parse expects to return string[] but we need to return string.
103-
// This is a weird consequence of implementing an array flag. The oclif parser splits the input (e.g. "thing1,thing2")
104-
// on the delimiter and passes each value individually to the parse function. However, the return type needs to be
105-
// string[] so that upstream consumers have the correct flag typings.
106-
parse: async (input, ctx) => {
107-
const inputParts = ctx.token.input.split(',').map((i) => i.trim());
108-
if (inputParts.length > 1) {
109-
await Lifecycle.getInstance().emitWarning(messages.getMessage('warning.arrayInputFormat'));
110-
}
111-
112-
return input;
113-
},
114101
});

test/unit/compatibility.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2024, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
import { expect } from 'chai';
8+
import { Command, Interfaces } from '@oclif/core';
9+
import { arrayWithDeprecation } from '../../src/compatibility.js';
10+
11+
describe('arrayWithDeprecation', () => {
12+
class TestCommand extends Command {
13+
public static flags = {
14+
things: arrayWithDeprecation({
15+
char: 'a',
16+
description: 'api version for the org',
17+
}),
18+
};
19+
20+
public async run(): Promise<Interfaces.InferredFlags<typeof TestCommand.flags>> {
21+
const { flags } = await this.parse(TestCommand);
22+
return flags;
23+
}
24+
}
25+
26+
it('should split the flags on comma', async () => {
27+
const result = await TestCommand.run(['--things', 'a,b,c']);
28+
expect(result.things).to.deep.equal(['a', 'b', 'c']);
29+
});
30+
31+
it('should split the flags on comma and ignore spaces', async () => {
32+
const result = await TestCommand.run(['--things', 'a, b, c']);
33+
expect(result.things).to.deep.equal(['a', 'b', 'c']);
34+
});
35+
36+
it('should not split on escaped commas', async () => {
37+
const result = await TestCommand.run(['--things', 'a\\,b,c']);
38+
expect(result.things).to.deep.equal(['a,b', 'c']);
39+
});
40+
41+
it('should allow multiple flag inputs', async () => {
42+
const result = await TestCommand.run(['--things', 'a', '--things', 'b', '--things', 'c']);
43+
expect(result.things).to.deep.equal(['a', 'b', 'c']);
44+
});
45+
});

0 commit comments

Comments
 (0)