Skip to content

Include context command functionality#98

Merged
wolfo951 merged 9 commits intomainfrom
wolfo951/context-implementation
Apr 14, 2025
Merged

Include context command functionality#98
wolfo951 merged 9 commits intomainfrom
wolfo951/context-implementation

Conversation

@wolfo951
Copy link
Copy Markdown
Contributor

@wolfo951 wolfo951 commented Apr 9, 2025

With this change, there will be 3 new commands:

1. itp context info

With this command, users can check their current context information. Ex:

{ 
    "iModelId": "<iModelId>", 
    "iTwinId": "<iTwinId>"
}

2. itp context set

With this command, users will be able to set iTwinId or/and iModelId for the context to be used across the CLI

itp context set --itwin-id <iTwinId>
itp context set --itwin-id <iTwinId> --imodel-id <iModelId>

3. itp context clear

With this command, users can clear existing context so that the values would not be referenced in the upcoming command execution.

Notes:

Once the context has been set, the user can execute commands like:
itp itwin info --json and get information about the itwin that is stored in the context

Priority:

From highest to lowest:

  1. Flag input (will override anything else)
  2. Context input (will override environment variables)
  3. Environemnt input
  4. If value is not provided, command will display an exception with message requesting for a flag with a value

Copy link
Copy Markdown
Collaborator

@Nadegamra Nadegamra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the problems I see with the current context set command implementation:

  1. It is possible to set unrelated itwin-id and imodel-id values. This could cause failure in commands, that use both flags.
  2. You are able to have only imodel-id set without having the itwin-id set. This would cause some commands to fail, when both flags are used and this situation could be avoided entirely by fetching the imodel and getting the itwin-id from there.

@wolfo951 wolfo951 linked an issue Apr 10, 2025 that may be closed by this pull request
@wolfo951
Copy link
Copy Markdown
Contributor Author

Here are the problems I see with the current context set command implementation:

  1. It is possible to set unrelated itwin-id and imodel-id values. This could cause failure in commands, that use both flags.
  2. You are able to have only imodel-id set without having the itwin-id set. This would cause some commands to fail, when both flags are used and this situation could be avoided entirely by fetching the imodel and getting the itwin-id from there.

@Nadegamra Included the auto fetch for itwin-id when only imodel-id is provided. Also added verification for both itwin-id and imodel-id

Comment thread src/commands/context/set.ts Outdated
@Nadegamra
Copy link
Copy Markdown
Collaborator

Currently there are no integration tests for the iTwin/IModel context functionality

@wolfo951
Copy link
Copy Markdown
Contributor Author

Currently there are no integration tests for the iTwin/IModel context functionality

Added integration tests

Nadegamra
Nadegamra previously approved these changes Apr 10, 2025
Comment thread docs/context/set.md Outdated
Comment thread docs/context/set.md Outdated
Nadegamra
Nadegamra previously approved these changes Apr 11, 2025
@wolfo951 wolfo951 merged commit 0bea971 into main Apr 14, 2025
11 checks passed
linasburneika pushed a commit that referenced this pull request Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to set imodel/itwin id's so commands do not require them

2 participants