Skip to content

Commit 340c52e

Browse files
authored
Assign env variables to each itwinid and imodelid flag (#102)
1 parent 35584a4 commit 340c52e

53 files changed

Lines changed: 199 additions & 302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integration-tests/formating/formatting.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,29 @@ describe('Command formatting tests', async () => {
3232
expect(flag, `Flag '${flagName}' in command '${command.cmd.id}' is missing the 'required' property`).to.have.property('required');
3333

3434
if(flag.type === 'option') {
35-
console.log(flag);
3635
expect(flag, `Flag '${flagName}' in command '${command.cmd.id}' is missing a valid 'helpValue'`).to.have.property('helpValue').to.be.a('string').and.not.be.empty;
3736
}
3837
}
3938
}
4039
});
40+
41+
it('Should ensure all itwin-id flags have env properties', async () => {
42+
for (const command of allCommands) {
43+
const iTwinIdFlag = command.flags.find(([name, _]) => name === "itwin-id");
44+
if (iTwinIdFlag) {
45+
expect(iTwinIdFlag[1].env, `Flag 'itwin-id' in command '${command.cmd.id}' is missing the 'env' property`).to.be.a('string').and.be.equals("ITP_ITWIN_ID");
46+
}
47+
}
48+
});
49+
50+
it('Should ensure all imodel-id flags have env properties', async () => {
51+
for (const command of allCommands) {
52+
const iTwinIdFlag = command.flags.find(([name, _]) => name === "imodel-id");
53+
if (iTwinIdFlag) {
54+
expect(iTwinIdFlag[1].env, `Flag 'imodel-id' in command '${command.cmd.id}' is missing the 'env' property`).to.be.a('string').and.be.equals("ITP_IMODEL_ID");
55+
}
56+
}
57+
});
4158
});
4259

4360
type CommandWithFlags = {

src/commands/access-control/group/create.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Flags } from "@oclif/core";
77

88
import { apiReference } from "../../../extensions/api-reference.js";
99
import BaseCommand from "../../../extensions/base-command.js";
10+
import { CustomFlags } from "../../../extensions/custom-flags.js";
1011

1112
export default class CreateAccessControlGroup extends BaseCommand {
1213
static apiReference : apiReference = {
@@ -30,11 +31,8 @@ export default class CreateAccessControlGroup extends BaseCommand {
3031
helpValue: '<string>',
3132
required: true,
3233
}),
33-
"itwin-id": Flags.string({
34-
char: 'i',
35-
description: 'The ID of the iTwin where the group is being created.',
36-
helpValue: '<string>',
37-
required: true,
34+
"itwin-id": CustomFlags.iTwinIDFlag({
35+
description: 'The ID of the iTwin where the group is being created.'
3836
}),
3937
name: Flags.string({
4038
char: 'n',

src/commands/access-control/group/delete.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../extensions/custom-flags.js";
910

1011
export default class DeleteAccessControlGroup extends BaseCommand {
1112
static description = 'Delete an existing group from an iTwin.';
@@ -24,11 +25,8 @@ export default class DeleteAccessControlGroup extends BaseCommand {
2425
helpValue: '<string>',
2526
required: true,
2627
}),
27-
"itwin-id": Flags.string({
28-
char: 'i',
28+
"itwin-id": CustomFlags.iTwinIDFlag({
2929
description: 'The ID of the iTwin where the group exists.',
30-
helpValue: '<string>',
31-
required: true,
3230
}),
3331
};
3432

src/commands/access-control/group/info.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../extensions/custom-flags.js";
910

1011
export default class AccessControlGroupInfo extends BaseCommand {
1112
static description = 'Retrieve details about a specific group in an iTwin.';
@@ -24,11 +25,8 @@ export default class AccessControlGroupInfo extends BaseCommand {
2425
helpValue: '<string>',
2526
required: true,
2627
}),
27-
"itwin-id": Flags.string({
28-
char: 'i',
29-
description: 'The ID of the iTwin where the group exists.',
30-
helpValue: '<string>',
31-
required: true,
28+
"itwin-id": CustomFlags.iTwinIDFlag({
29+
description: 'The ID of the iTwin where the group exists.'
3230
}),
3331
};
3432

src/commands/access-control/group/list.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* See LICENSE.md in the project root for license terms and full copyright notice.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Flags } from "@oclif/core";
7-
86
import BaseCommand from "../../../extensions/base-command.js";
7+
import { CustomFlags } from "../../../extensions/custom-flags.js";
98

109
export default class ListAccessControlGroups extends BaseCommand {
1110
static description = 'List all groups for a specific iTwin.';
@@ -18,11 +17,8 @@ export default class ListAccessControlGroups extends BaseCommand {
1817
];
1918

2019
static flags = {
21-
"itwin-id": Flags.string({
22-
char: 'i',
23-
description: 'The ID of the iTwin whose groups you want to list.',
24-
helpValue: '<string>',
25-
required: true,
20+
"itwin-id": CustomFlags.iTwinIDFlag({
21+
description: 'The ID of the iTwin whose groups you want to list.'
2622
}),
2723
};
2824

src/commands/access-control/group/update.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../extensions/custom-flags.js";
910

1011
export default class UpdateAccessControlGroup extends BaseCommand {
1112
static description = 'Update the details of an existing group in an iTwin.';
@@ -38,11 +39,8 @@ export default class UpdateAccessControlGroup extends BaseCommand {
3839
helpValue: '<string>',
3940
multiple: true,
4041
}),
41-
"itwin-id": Flags.string({
42-
char: 'i',
43-
description: 'The ID of the iTwin where the group exists.',
44-
helpValue: '<string>',
45-
required: true,
42+
"itwin-id": CustomFlags.iTwinIDFlag({
43+
description: 'The ID of the iTwin where the group exists.'
4644
}),
4745
member: Flags.string({
4846
description: 'A list of members (emails) to be assigned to the group.',

src/commands/access-control/member/group/add.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../../extensions/custom-flags.js";
910
import { GroupMember } from "../../../../services/access-control-client/models/group.js";
1011

1112
export default class AddGroupMembers extends BaseCommand {
@@ -24,11 +25,8 @@ export default class AddGroupMembers extends BaseCommand {
2425
helpValue: '<string>',
2526
required: true
2627
}),
27-
"itwin-id": Flags.string({
28-
char: 'i',
29-
description: 'The ID of the iTwin to which the groups will be added.',
30-
helpValue: '<string>',
31-
required: true,
28+
"itwin-id": CustomFlags.iTwinIDFlag({
29+
description: 'The ID of the iTwin to which the groups will be added.'
3230
}),
3331
};
3432

src/commands/access-control/member/group/delete.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../../extensions/custom-flags.js";
910

1011
export default class DeleteGroupMember extends BaseCommand {
1112
static description = 'Remove a group from an iTwin.';
@@ -24,11 +25,8 @@ export default class DeleteGroupMember extends BaseCommand {
2425
helpValue: '<string>',
2526
required: true,
2627
}),
27-
"itwin-id": Flags.string({
28-
char: 'i',
29-
description: 'The ID of the iTwin where the group is a member.',
30-
helpValue: '<string>',
31-
required: true,
28+
"itwin-id": CustomFlags.iTwinIDFlag({
29+
description: 'The ID of the iTwin where the group is a member.'
3230
}),
3331
};
3432

src/commands/access-control/member/group/info.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Flags } from "@oclif/core";
77

88
import BaseCommand from "../../../../extensions/base-command.js";
9+
import { CustomFlags } from "../../../../extensions/custom-flags.js";
910

1011
export default class InfoGroupMember extends BaseCommand {
1112
static description = 'Retrieve details about a specific group member in an iTwin.';
@@ -24,11 +25,8 @@ export default class InfoGroupMember extends BaseCommand {
2425
helpValue: '<string>',
2526
required: true,
2627
}),
27-
"itwin-id": Flags.string({
28-
char: 'i',
29-
description: 'The ID of the iTwin where the group is a member.',
30-
helpValue: '<string>',
31-
required: true,
28+
"itwin-id": CustomFlags.iTwinIDFlag({
29+
description: 'The ID of the iTwin where the group is a member.'
3230
}),
3331
};
3432

src/commands/access-control/member/group/list.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* See LICENSE.md in the project root for license terms and full copyright notice.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Flags } from "@oclif/core";
7-
86
import BaseCommand from "../../../../extensions/base-command.js";
7+
import { CustomFlags } from "../../../../extensions/custom-flags.js";
98

109
export default class ListGroupMembers extends BaseCommand {
1110
static description = 'List all group members of an iTwin.';
@@ -18,11 +17,8 @@ export default class ListGroupMembers extends BaseCommand {
1817
];
1918

2019
static flags = {
21-
"itwin-id": Flags.string({
22-
char: 'i',
20+
"itwin-id": CustomFlags.iTwinIDFlag({
2321
description: 'The ID of the iTwin whose group members you want to list.',
24-
helpValue: '<string>',
25-
required: true,
2622
}),
2723
};
2824

0 commit comments

Comments
 (0)