diff --git a/integration-tests/formating/formatting.test.ts b/integration-tests/formating/formatting.test.ts index d683088c..2ce2ad55 100644 --- a/integration-tests/formating/formatting.test.ts +++ b/integration-tests/formating/formatting.test.ts @@ -32,12 +32,29 @@ describe('Command formatting tests', async () => { expect(flag, `Flag '${flagName}' in command '${command.cmd.id}' is missing the 'required' property`).to.have.property('required'); if(flag.type === 'option') { - console.log(flag); 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; } } } }); + + it('Should ensure all itwin-id flags have env properties', async () => { + for (const command of allCommands) { + const iTwinIdFlag = command.flags.find(([name, _]) => name === "itwin-id"); + if (iTwinIdFlag) { + 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"); + } + } + }); + + it('Should ensure all imodel-id flags have env properties', async () => { + for (const command of allCommands) { + const iTwinIdFlag = command.flags.find(([name, _]) => name === "imodel-id"); + if (iTwinIdFlag) { + 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"); + } + } + }); }); type CommandWithFlags = { diff --git a/src/commands/access-control/group/create.ts b/src/commands/access-control/group/create.ts index 52c9a475..d8602a6e 100644 --- a/src/commands/access-control/group/create.ts +++ b/src/commands/access-control/group/create.ts @@ -7,6 +7,7 @@ import { Flags } from "@oclif/core"; import { apiReference } from "../../../extensions/api-reference.js"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class CreateAccessControlGroup extends BaseCommand { static apiReference : apiReference = { @@ -30,11 +31,8 @@ export default class CreateAccessControlGroup extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the group is being created.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the group is being created.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/access-control/group/delete.ts b/src/commands/access-control/group/delete.ts index 2f3da96f..e8df09a4 100644 --- a/src/commands/access-control/group/delete.ts +++ b/src/commands/access-control/group/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class DeleteAccessControlGroup extends BaseCommand { static description = 'Delete an existing group from an iTwin.'; @@ -24,11 +25,8 @@ export default class DeleteAccessControlGroup extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin where the group exists.', - helpValue: '', - required: true, }), }; diff --git a/src/commands/access-control/group/info.ts b/src/commands/access-control/group/info.ts index c75d5edc..2f3f28f6 100644 --- a/src/commands/access-control/group/info.ts +++ b/src/commands/access-control/group/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class AccessControlGroupInfo extends BaseCommand { static description = 'Retrieve details about a specific group in an iTwin.'; @@ -24,11 +25,8 @@ export default class AccessControlGroupInfo extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the group exists.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the group exists.' }), }; diff --git a/src/commands/access-control/group/list.ts b/src/commands/access-control/group/list.ts index b9e573fe..d8aec489 100644 --- a/src/commands/access-control/group/list.ts +++ b/src/commands/access-control/group/list.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListAccessControlGroups extends BaseCommand { static description = 'List all groups for a specific iTwin.'; @@ -18,11 +17,8 @@ export default class ListAccessControlGroups extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin whose groups you want to list.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin whose groups you want to list.' }), }; diff --git a/src/commands/access-control/group/update.ts b/src/commands/access-control/group/update.ts index 436e9a10..c3a57113 100644 --- a/src/commands/access-control/group/update.ts +++ b/src/commands/access-control/group/update.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class UpdateAccessControlGroup extends BaseCommand { static description = 'Update the details of an existing group in an iTwin.'; @@ -38,11 +39,8 @@ export default class UpdateAccessControlGroup extends BaseCommand { helpValue: '', multiple: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the group exists.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the group exists.' }), member: Flags.string({ description: 'A list of members (emails) to be assigned to the group.', diff --git a/src/commands/access-control/member/group/add.ts b/src/commands/access-control/member/group/add.ts index 48d0d53b..f46aa50d 100644 --- a/src/commands/access-control/member/group/add.ts +++ b/src/commands/access-control/member/group/add.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; import { GroupMember } from "../../../../services/access-control-client/models/group.js"; export default class AddGroupMembers extends BaseCommand { @@ -24,11 +25,8 @@ export default class AddGroupMembers extends BaseCommand { helpValue: '', required: true }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the groups will be added.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the groups will be added.' }), }; diff --git a/src/commands/access-control/member/group/delete.ts b/src/commands/access-control/member/group/delete.ts index cf1c49f2..73e8436e 100644 --- a/src/commands/access-control/member/group/delete.ts +++ b/src/commands/access-control/member/group/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class DeleteGroupMember extends BaseCommand { static description = 'Remove a group from an iTwin.'; @@ -24,11 +25,8 @@ export default class DeleteGroupMember extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the group is a member.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the group is a member.' }), }; diff --git a/src/commands/access-control/member/group/info.ts b/src/commands/access-control/member/group/info.ts index d04574c1..5a1f7953 100644 --- a/src/commands/access-control/member/group/info.ts +++ b/src/commands/access-control/member/group/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class InfoGroupMember extends BaseCommand { static description = 'Retrieve details about a specific group member in an iTwin.'; @@ -24,11 +25,8 @@ export default class InfoGroupMember extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the group is a member.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the group is a member.' }), }; diff --git a/src/commands/access-control/member/group/list.ts b/src/commands/access-control/member/group/list.ts index cc49edf2..0dea435d 100644 --- a/src/commands/access-control/member/group/list.ts +++ b/src/commands/access-control/member/group/list.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class ListGroupMembers extends BaseCommand { static description = 'List all group members of an iTwin.'; @@ -18,11 +17,8 @@ export default class ListGroupMembers extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin whose group members you want to list.', - helpValue: '', - required: true, }), }; diff --git a/src/commands/access-control/member/group/update.ts b/src/commands/access-control/member/group/update.ts index aa2d5694..d394d611 100644 --- a/src/commands/access-control/member/group/update.ts +++ b/src/commands/access-control/member/group/update.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class UpdateGroupMember extends BaseCommand { static description = 'Update the role assignments for a group in an iTwin.'; @@ -24,11 +25,8 @@ export default class UpdateGroupMember extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the groups will be added.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the groups will be added.' }), "role-id": Flags.string({ description: 'A list of role IDs to assign to the group.', diff --git a/src/commands/access-control/member/invitations.ts b/src/commands/access-control/member/invitations.ts index c2211ac7..e9ddfe2d 100644 --- a/src/commands/access-control/member/invitations.ts +++ b/src/commands/access-control/member/invitations.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class AccessControlMemberInvitations extends BaseCommand { static description = "Retrieve the list of pending invitations for an iTwin's members."; @@ -18,11 +17,8 @@ export default class AccessControlMemberInvitations extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: "The ID of the iTwin whose member invitations you want to retrieve.", - helpValue: '', - required: true, }), }; diff --git a/src/commands/access-control/member/owner/add.ts b/src/commands/access-control/member/owner/add.ts index 7c0fbd78..8d1bdff3 100644 --- a/src/commands/access-control/member/owner/add.ts +++ b/src/commands/access-control/member/owner/add.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class AddOwner extends BaseCommand { static description = 'Add a new owner to an iTwin by email.'; @@ -23,11 +24,8 @@ export default class AddOwner extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the owner will be added.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the owner will be added.' }), }; diff --git a/src/commands/access-control/member/owner/delete.ts b/src/commands/access-control/member/owner/delete.ts index 15458535..24653054 100644 --- a/src/commands/access-control/member/owner/delete.ts +++ b/src/commands/access-control/member/owner/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class DeleteOwner extends BaseCommand { static description = 'Remove an owner from an iTwin by their member ID.'; @@ -18,11 +19,8 @@ export default class DeleteOwner extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin from which the owner will be removed.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin from which the owner will be removed.' }), "member-id": Flags.string({ description: 'The ID of the owner to be removed.', diff --git a/src/commands/access-control/member/owner/list.ts b/src/commands/access-control/member/owner/list.ts index 01889194..6951a0f8 100644 --- a/src/commands/access-control/member/owner/list.ts +++ b/src/commands/access-control/member/owner/list.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class ListOwners extends BaseCommand { static description = 'List all owners of a specific iTwin.'; @@ -18,11 +17,8 @@ export default class ListOwners extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin whose owners you want to list.', - helpValue: '', - required: true, }), }; diff --git a/src/commands/access-control/member/user/add.ts b/src/commands/access-control/member/user/add.ts index e97a9426..cbb32166 100644 --- a/src/commands/access-control/member/user/add.ts +++ b/src/commands/access-control/member/user/add.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; import { addMember } from "../../../../services/access-control-client/models/members.js"; export default class AddUserMembers extends BaseCommand { @@ -19,11 +20,8 @@ export default class AddUserMembers extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the users will be added.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the users will be added.' }), members: Flags.string({ description: 'A list of members to add, each with an email and a list of role IDs.', diff --git a/src/commands/access-control/member/user/delete.ts b/src/commands/access-control/member/user/delete.ts index 480bafd8..93aa9324 100644 --- a/src/commands/access-control/member/user/delete.ts +++ b/src/commands/access-control/member/user/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class DeleteUserMember extends BaseCommand { static description = 'Remove a user from an iTwin.'; @@ -18,11 +19,8 @@ export default class DeleteUserMember extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the user is a member.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the user is a member.' }), "member-id": Flags.string({ description: 'The ID of the user to remove from the iTwin.', diff --git a/src/commands/access-control/member/user/info.ts b/src/commands/access-control/member/user/info.ts index 4a6fd887..431735ca 100644 --- a/src/commands/access-control/member/user/info.ts +++ b/src/commands/access-control/member/user/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class InfoUserMember extends BaseCommand { static description = 'Retrieve details about a specific user member in an iTwin.'; @@ -18,11 +19,8 @@ export default class InfoUserMember extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the user is a member.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the user is a member.' }), "member-id": Flags.string({ description: 'The ID of the user to retrieve information about.', diff --git a/src/commands/access-control/member/user/list.ts b/src/commands/access-control/member/user/list.ts index 31661bd3..6685126f 100644 --- a/src/commands/access-control/member/user/list.ts +++ b/src/commands/access-control/member/user/list.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class ListUserMembers extends BaseCommand { static description = 'Retrieve details about a specific user member in an iTwin.'; @@ -18,11 +17,8 @@ export default class ListUserMembers extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin whose user members you want to list.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin whose user members you want to list.' }), }; diff --git a/src/commands/access-control/member/user/update.ts b/src/commands/access-control/member/user/update.ts index 4de70a0e..d0097d21 100644 --- a/src/commands/access-control/member/user/update.ts +++ b/src/commands/access-control/member/user/update.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../../extensions/base-command.js"; +import { CustomFlags } from "../../../../extensions/custom-flags.js"; export default class UpdateUserMember extends BaseCommand { static description = 'Update the role assignments for a user in an iTwin.'; @@ -18,11 +19,8 @@ export default class UpdateUserMember extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin where the user is a member.', - helpValue: '', - required: true, }), "member-id": Flags.string({ description: 'The ID of the user whose roles will be updated.', diff --git a/src/commands/access-control/permissions/me.ts b/src/commands/access-control/permissions/me.ts index ab7e8ea1..bb1ce7ef 100644 --- a/src/commands/access-control/permissions/me.ts +++ b/src/commands/access-control/permissions/me.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class MyPermissions extends BaseCommand { static description = 'Retrieve a list of your permissions on a specified iTwin.'; @@ -18,11 +17,8 @@ export default class MyPermissions extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin for which the role is being created.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin for which the role is being created.' }), }; diff --git a/src/commands/access-control/role/create.ts b/src/commands/access-control/role/create.ts index b364d230..f8a3e564 100644 --- a/src/commands/access-control/role/create.ts +++ b/src/commands/access-control/role/create.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class CreateRole extends BaseCommand { static description = 'Create a new role for an iTwin. To assign permissions after creation, use itp access-control role update.'; @@ -24,11 +25,8 @@ export default class CreateRole extends BaseCommand { helpValue: '', required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to retrieve permissions.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to retrieve permissions.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/access-control/role/delete.ts b/src/commands/access-control/role/delete.ts index f220eb74..239cf65b 100644 --- a/src/commands/access-control/role/delete.ts +++ b/src/commands/access-control/role/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class DeleteRole extends BaseCommand { static description = 'Delete an existing role from an iTwin.'; @@ -18,11 +19,8 @@ export default class DeleteRole extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the role exists.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the role exists.' }), "role-id": Flags.string({ description: 'The ID of the role to be deleted.', diff --git a/src/commands/access-control/role/info.ts b/src/commands/access-control/role/info.ts index daf52f63..0ae2e6e5 100644 --- a/src/commands/access-control/role/info.ts +++ b/src/commands/access-control/role/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class InfoRole extends BaseCommand { static description = 'Retrieve details about a specific role in an iTwin.'; @@ -18,11 +19,8 @@ export default class InfoRole extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin where the role exists.', - helpValue: '', - required: true, }), "role-id": Flags.string({ description: 'The ID of the role to retrieve information about.', diff --git a/src/commands/access-control/role/list.ts b/src/commands/access-control/role/list.ts index 76708b0d..20c08890 100644 --- a/src/commands/access-control/role/list.ts +++ b/src/commands/access-control/role/list.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListRoles extends BaseCommand { static description = 'List all roles for a specific iTwin.'; @@ -18,11 +17,8 @@ export default class ListRoles extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', + "itwin-id": CustomFlags.iTwinIDFlag({ description: 'The ID of the iTwin whose roles you want to list.', - helpValue: '', - required: true, }), }; diff --git a/src/commands/access-control/role/update.ts b/src/commands/access-control/role/update.ts index 3c396c83..0d84762b 100644 --- a/src/commands/access-control/role/update.ts +++ b/src/commands/access-control/role/update.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class UpdateRole extends BaseCommand { static description = 'Update the details of an existing role in an iTwin.'; @@ -28,11 +29,8 @@ export default class UpdateRole extends BaseCommand { helpValue: '', required: false, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the role exists.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the role exists.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/changed-elements/changesets.ts b/src/commands/changed-elements/changesets.ts index 2fb10664..b0b6f834 100644 --- a/src/commands/changed-elements/changesets.ts +++ b/src/commands/changed-elements/changesets.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class GetChangesetStatus extends BaseCommand { static description = 'Get the processing status of changesets in an iModel to see which are ready for comparison.'; @@ -26,17 +27,11 @@ export default class GetChangesetStatus extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel.', - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel.' }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin.', - helpValue: '', - required: true + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin.' }), skip: Flags.integer({ description: 'Skip a number of changesets in the result.', diff --git a/src/commands/changed-elements/comparison.ts b/src/commands/changed-elements/comparison.ts index 83de6bc3..85493820 100644 --- a/src/commands/changed-elements/comparison.ts +++ b/src/commands/changed-elements/comparison.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ChangedElementsComparison extends BaseCommand { static description = 'Compare changes between two changesets in an iModel.'; @@ -32,17 +33,11 @@ export default class ChangedElementsComparison extends BaseCommand { helpValue: '', required: true }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel to compare changesets for.', - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel to compare changesets for.' }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin associated with the iModel.', - helpValue: '', - required: true + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin associated with the iModel.' }) }; diff --git a/src/commands/changed-elements/disable.ts b/src/commands/changed-elements/disable.ts index f53c6eba..cf298e46 100644 --- a/src/commands/changed-elements/disable.ts +++ b/src/commands/changed-elements/disable.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ChangedElementsDisable extends BaseCommand { static description = "Disable change tracking for a specified iModel."; @@ -18,17 +17,11 @@ export default class ChangedElementsDisable extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: "The ID of the iModel where change tracking should be disabled.", - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: "The ID of the iModel where change tracking should be disabled." }), - "itwin-id": Flags.string({ - char: 'i', - description: "The ID of the iTwin associated with the iModel.", - helpValue: '', - required: true + "itwin-id": CustomFlags.iTwinIDFlag({ + description: "The ID of the iTwin associated with the iModel." }), }; diff --git a/src/commands/changed-elements/enable.ts b/src/commands/changed-elements/enable.ts index 7c3c15f0..c072f1ef 100644 --- a/src/commands/changed-elements/enable.ts +++ b/src/commands/changed-elements/enable.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ChangedElementsEnable extends BaseCommand { static description = "Enable change tracking for a specified iModel."; @@ -18,17 +17,11 @@ export default class ChangedElementsEnable extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: "The ID of the iModel where change tracking should be enabled.", - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: "The ID of the iModel where change tracking should be enabled." }), - "itwin-id": Flags.string({ - char: 'i', - description: "The ID of the iTwin associated with the iModel.", - helpValue: '', - required: true + "itwin-id": CustomFlags.iTwinIDFlag({ + description: "The ID of the iTwin associated with the iModel." }), }; diff --git a/src/commands/changed-elements/info.ts b/src/commands/changed-elements/info.ts index d40170ae..c925e876 100644 --- a/src/commands/changed-elements/info.ts +++ b/src/commands/changed-elements/info.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ChangedElementsInfo extends BaseCommand { static description = "Retrieve change tracking information for a specified iModel."; @@ -18,16 +17,11 @@ export default class ChangedElementsInfo extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: "The ID of the iModel to retrieve tracking information for.", - helpValue: '', - required: true }), - "itwin-id": Flags.string({ - char: 'i', - description: "The ID of the iTwin associated with the iModel.", - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: "The ID of the iModel to retrieve tracking information for." + }), + "itwin-id": CustomFlags.iTwinIDFlag({ + description: "The ID of the iTwin associated with the iModel." }), }; diff --git a/src/commands/imodel/changeset/info.ts b/src/commands/imodel/changeset/info.ts index 50e2070a..49ef0181 100644 --- a/src/commands/imodel/changeset/info.ts +++ b/src/commands/imodel/changeset/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ChangesetInfo extends BaseCommand { static description = 'Retrieve details about a specific changeset of an iModel.'; @@ -23,11 +24,8 @@ export default class ChangesetInfo extends BaseCommand { helpValue: '', required: true, }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel whose changeset you want to retrieve.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel whose changeset you want to retrieve.' }), }; diff --git a/src/commands/imodel/changeset/list.ts b/src/commands/imodel/changeset/list.ts index 745d137f..bb7d32a8 100644 --- a/src/commands/imodel/changeset/list.ts +++ b/src/commands/imodel/changeset/list.ts @@ -7,6 +7,7 @@ import { Changeset, ChangesetOrderByProperty, OrderBy, OrderByOperator, take, to import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListChangesets extends BaseCommand { static description = 'List all changesets for a specific iModel.'; @@ -36,11 +37,8 @@ export default class ListChangesets extends BaseCommand { helpValue: '', required: false, }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel whose changesets you want to list.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel whose changesets you want to list.' }), "last-index": Flags.integer({ description: 'List changesets up to a specific index (inclusive).', diff --git a/src/commands/imodel/connection/create.ts b/src/commands/imodel/connection/create.ts index be6d203e..d6a12efe 100644 --- a/src/commands/imodel/connection/create.ts +++ b/src/commands/imodel/connection/create.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; import { authenticationType } from "../../../services/synchronizationClient/models/authentication-type.js"; import { connectorType } from "../../../services/synchronizationClient/models/connector-type.js"; import { storageFileCreate } from "../../../services/synchronizationClient/models/storage-file-create.js"; @@ -60,11 +61,8 @@ export default class CreateConnection extends BaseCommand { multiple: true, required: true }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel.', - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/connection/list.ts b/src/commands/imodel/connection/list.ts index c06a2313..5c7d7ddc 100644 --- a/src/commands/imodel/connection/list.ts +++ b/src/commands/imodel/connection/list.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListConnections extends BaseCommand { static description = 'List all storage connections for a specific iModel.'; @@ -26,11 +27,8 @@ export default class ListConnections extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel whose storage connections you want to list.', - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel whose storage connections you want to list.' }), skip: Flags.integer({ description: 'The number of changesets to skip.', diff --git a/src/commands/imodel/create.ts b/src/commands/imodel/create.ts index a683b3fa..7515f874 100644 --- a/src/commands/imodel/create.ts +++ b/src/commands/imodel/create.ts @@ -7,6 +7,7 @@ import { Extent } from "@itwin/imodels-client-management"; import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class CreateIModel extends BaseCommand { static description = 'Creates an iModel in an iTwin'; @@ -34,11 +35,8 @@ export default class CreateIModel extends BaseCommand { helpValue: '', required: false, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin where the iModel should be created.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin where the iModel should be created.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/delete.ts b/src/commands/imodel/delete.ts index 8f9ac347..637c8f88 100644 --- a/src/commands/imodel/delete.ts +++ b/src/commands/imodel/delete.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class DeleteIModel extends BaseCommand { static description = 'Delete an existing iModel.'; @@ -18,11 +17,8 @@ export default class DeleteIModel extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel to delete.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel to delete.' }), }; diff --git a/src/commands/imodel/info.ts b/src/commands/imodel/info.ts index 88274a20..4caf9890 100644 --- a/src/commands/imodel/info.ts +++ b/src/commands/imodel/info.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export class IModelInfo extends BaseCommand { static description = 'Retrieve metadata for the specified Model'; @@ -18,11 +17,8 @@ export class IModelInfo extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel to retrieve information for.', - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel to retrieve information for.' }), }; diff --git a/src/commands/imodel/list.ts b/src/commands/imodel/list.ts index 8e8e355b..8731d972 100644 --- a/src/commands/imodel/list.ts +++ b/src/commands/imodel/list.ts @@ -7,6 +7,7 @@ import { IModel, IModelOrderByProperty, OrderBy } from "@itwin/imodels-client-ma import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ListIModels extends BaseCommand { static description = 'Retrieve a list of iModels'; @@ -31,11 +32,8 @@ export default class ListIModels extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to list iModels for.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to list iModels for.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/named-version/create.ts b/src/commands/imodel/named-version/create.ts index e29b7f83..b7f2c6f4 100644 --- a/src/commands/imodel/named-version/create.ts +++ b/src/commands/imodel/named-version/create.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class CreateNamedVersion extends BaseCommand { static description = 'Create a new named version for a specific changeset in an iModel.'; @@ -37,11 +38,8 @@ export default class CreateNamedVersion extends BaseCommand { helpValue: '', required: false, }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel where the named version will be created.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel where the named version will be created.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/named-version/info.ts b/src/commands/imodel/named-version/info.ts index f069cee9..60fb0b2a 100644 --- a/src/commands/imodel/named-version/info.ts +++ b/src/commands/imodel/named-version/info.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class NamedVersionInfo extends BaseCommand { static description = 'Retrieve details about a specific named version in an iModel.'; @@ -18,11 +19,8 @@ export default class NamedVersionInfo extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel whose named version you want to retrieve.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel whose named version you want to retrieve.' }), "named-version-id": Flags.string({ description: 'The ID of the named version.', diff --git a/src/commands/imodel/named-version/list.ts b/src/commands/imodel/named-version/list.ts index 2bc1af3a..78eb6579 100644 --- a/src/commands/imodel/named-version/list.ts +++ b/src/commands/imodel/named-version/list.ts @@ -7,6 +7,7 @@ import { NamedVersion, NamedVersionOrderByProperty, OrderBy, OrderByOperator } f import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListNamedVersions extends BaseCommand { static description = 'List all named versions for a specific iModel.'; @@ -31,11 +32,8 @@ export default class ListNamedVersions extends BaseCommand { ]; static flags = { - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel whose named versions you want to list.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel whose named versions you want to list.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/populate.ts b/src/commands/imodel/populate.ts index 0f36d167..d9932053 100644 --- a/src/commands/imodel/populate.ts +++ b/src/commands/imodel/populate.ts @@ -11,6 +11,7 @@ import fs from "node:fs" import path from "node:path" import BaseCommand from "../../extensions/base-command.js" +import { CustomFlags } from "../../extensions/custom-flags.js" import { authorizationInformation } from "../../services/authorization-client/authorization-type.js" import { fileUpload } from "../../services/storage-client/models/file-upload.js" import { itemsWithFolderLink } from "../../services/storage-client/models/items-with-folder-link.js" @@ -76,11 +77,8 @@ export default class PopulateIModel extends BaseCommand { multiple: true, required: true }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel to populate.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel to populate.' }), "no-wait": Flags.boolean({ description: 'Do not wait for the synchronization process to complete.', diff --git a/src/commands/imodel/update.ts b/src/commands/imodel/update.ts index 8dba068d..ae700799 100644 --- a/src/commands/imodel/update.ts +++ b/src/commands/imodel/update.ts @@ -7,6 +7,7 @@ import { Extent } from "@itwin/imodels-client-management"; import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class UpdateCommand extends BaseCommand { static description = 'Update an iModel in an iTwin'; @@ -30,11 +31,8 @@ export default class UpdateCommand extends BaseCommand { helpValue: '', required: false, }), - "imodel-id": Flags.string({ - char: 'm', - description: 'The ID of the iModel to update.', - helpValue: '', - required: true, + "imodel-id": CustomFlags.iModelIDFlag({ + description: 'The ID of the iModel to update.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/imodel/view/cesium-sandcastle.ts b/src/commands/imodel/view/cesium-sandcastle.ts index e2b74d2e..174144e3 100644 --- a/src/commands/imodel/view/cesium-sandcastle.ts +++ b/src/commands/imodel/view/cesium-sandcastle.ts @@ -9,6 +9,7 @@ import open from 'open'; import { deflate } from "pako"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; import { link, links } from "../../../services/general-models/links.js"; export default class CesiumSandcastle extends BaseCommand { @@ -35,11 +36,8 @@ export default class CesiumSandcastle extends BaseCommand { helpValue: '', required: false }), - "imodel-id": Flags.string({ - char: "m", - description: "iModel id to be viewed in Cesium Sandcastle.", - helpValue: '', - required: true + "imodel-id": CustomFlags.iModelIDFlag({ + description: "iModel id to be viewed in Cesium Sandcastle." }), "open": Flags.boolean({ description: "Open the URL in the browser.", diff --git a/src/commands/itwin/delete.ts b/src/commands/itwin/delete.ts index f58a1164..76815937 100644 --- a/src/commands/itwin/delete.ts +++ b/src/commands/itwin/delete.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class DeleteITwin extends BaseCommand { static description = 'Delete an iTwin'; @@ -18,11 +17,8 @@ export default class DeleteITwin extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'iTwin id.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'iTwin id.' }), }; diff --git a/src/commands/itwin/info.ts b/src/commands/itwin/info.ts index 31bc101c..fdb45a1c 100644 --- a/src/commands/itwin/info.ts +++ b/src/commands/itwin/info.ts @@ -3,9 +3,8 @@ * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ -import { Flags } from "@oclif/core"; - import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class ITwinInfo extends BaseCommand { static description = 'Retrieve metadata for the specified iTwin.'; @@ -18,11 +17,8 @@ export default class ITwinInfo extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to retrieve information about.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to retrieve information about.' }), }; diff --git a/src/commands/itwin/repository/create.ts b/src/commands/itwin/repository/create.ts index ca518c0d..df8fca87 100644 --- a/src/commands/itwin/repository/create.ts +++ b/src/commands/itwin/repository/create.ts @@ -7,6 +7,7 @@ import { RepositoryClass, RepositorySubClass } from "@itwin/itwins-client"; import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class CreateRepository extends BaseCommand { static description = 'Create a new repository URI for iTwin data.'; @@ -33,11 +34,8 @@ export default class CreateRepository extends BaseCommand { options: ['GeographicInformationSystem', 'Construction', 'Subsurface'], required: true, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the repository belongs.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the repository belongs.' }), "sub-class": Flags.string({ description: 'The subClass of your repository.', diff --git a/src/commands/itwin/repository/delete.ts b/src/commands/itwin/repository/delete.ts index 5d4c27f5..1a48e06f 100644 --- a/src/commands/itwin/repository/delete.ts +++ b/src/commands/itwin/repository/delete.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class DeleteRepository extends BaseCommand { static description = 'Delete a specified repository from an iTwin.'; @@ -18,11 +19,8 @@ export default class DeleteRepository extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to which the repository belongs.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to which the repository belongs.' }), "repository-id": Flags.string({ description: 'The ID of the repository to delete.', diff --git a/src/commands/itwin/repository/list.ts b/src/commands/itwin/repository/list.ts index 09cb5cee..4b533a1a 100644 --- a/src/commands/itwin/repository/list.ts +++ b/src/commands/itwin/repository/list.ts @@ -6,6 +6,7 @@ import { Flags } from "@oclif/core"; import BaseCommand from "../../../extensions/base-command.js"; +import { CustomFlags } from "../../../extensions/custom-flags.js"; export default class ListRepositories extends BaseCommand { static description = 'Retrieve a list of repositories for a specified iTwin.'; @@ -32,11 +33,8 @@ export default class ListRepositories extends BaseCommand { options: ["iModels", "RealityData", "Storage", "Forms", "Issues", "SensorData", "GeographicInformationSystem", "Construction", "Subsurface"], required: false }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin whose repositories should be retrieved.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin whose repositories should be retrieved.' }), "sub-class": Flags.string({ description: 'Specify a subClass of repositories. Only applicable for GeographicInformationSystem class.', diff --git a/src/commands/itwin/update.ts b/src/commands/itwin/update.ts index b57f2f1d..e01fcecf 100644 --- a/src/commands/itwin/update.ts +++ b/src/commands/itwin/update.ts @@ -7,6 +7,7 @@ import { ITwin } from "@itwin/itwins-client"; import { Flags } from "@oclif/core"; import BaseCommand from "../../extensions/base-command.js"; +import { CustomFlags } from "../../extensions/custom-flags.js"; export default class UpdateCommand extends BaseCommand { static description = 'Update an iTwin'; @@ -37,11 +38,8 @@ export default class UpdateCommand extends BaseCommand { helpValue: '', required: false, }), - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin to be updated.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin to be updated.' }), name: Flags.string({ char: 'n', diff --git a/src/commands/storage/root-folder.ts b/src/commands/storage/root-folder.ts index e0907472..499578d7 100644 --- a/src/commands/storage/root-folder.ts +++ b/src/commands/storage/root-folder.ts @@ -6,6 +6,7 @@ import { Flags } from '@oclif/core'; import BaseCommand from '../../extensions/base-command.js'; +import { CustomFlags } from '../../extensions/custom-flags.js'; export default class GetRootFolder extends BaseCommand { static description = 'Retrieve the top-level folders and files in an iTwin\'s storage.'; @@ -18,11 +19,8 @@ export default class GetRootFolder extends BaseCommand { ]; static flags = { - "itwin-id": Flags.string({ - char: 'i', - description: 'The ID of the iTwin whose top-level folders and files you want to retrieve.', - helpValue: '', - required: true, + "itwin-id": CustomFlags.iTwinIDFlag({ + description: 'The ID of the iTwin whose top-level folders and files you want to retrieve.' }), skip: Flags.integer({ description: 'The skip query option requests the number of items in the queried collection that are to be skipped and not included in the result.', diff --git a/src/extensions/custom-flags.ts b/src/extensions/custom-flags.ts new file mode 100644 index 00000000..63d69b81 --- /dev/null +++ b/src/extensions/custom-flags.ts @@ -0,0 +1,24 @@ +import { Flags } from "@oclif/core"; + +// eslint-disable-next-line unicorn/no-static-only-class +export class CustomFlags { + static iModelIDFlag = (config : CustomFlagConfig) => Flags.string({ + char: 'm', + description: config.description, + env: 'ITP_IMODEL_ID', + helpValue: '', + required: true + }); + + static iTwinIDFlag = (config : CustomFlagConfig) => Flags.string({ + char: 'i', + description: config.description, + env: 'ITP_ITWIN_ID', + helpValue: '', + required: true + }) +} + +export type CustomFlagConfig = { + description: string; +}; \ No newline at end of file