-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add --data-set and --new-data-set flags to add command #296
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds CLI support for selecting an existing dataset or forcing creation of a new dataset when running the add command.
Changes:
- Adds
--dataset <id>and--new-datasetflags to theaddCLI command and maps them intoAddOptions. - Extends
AddOptionswithdatasetId/createNewDatasetand forwards these intocreateStorageContextdataset options. - Updates unit tests to cover dataset option forwarding into storage context.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/commands/add.ts | Adds new CLI flags and maps them into AddOptions passed to runAdd. |
| src/add/types.ts | Extends AddOptions to include dataset selection fields. |
| src/add/add.ts | Forwards dataset selection fields into CreateStorageContextOptions.dataset. |
| src/test/unit/add.test.ts | Adds assertions that dataset selection fields are passed into storage context creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/commands/add.ts
Outdated
| .option('--dataset <id>', 'ID of the existing dataset to use') | ||
| .option('--new-dataset', 'Create a new dataset instead of using an existing one') |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--dataset and --new-dataset can currently be provided together, which produces ambiguous CLI intent (and results in both datasetId and createNewDataset potentially being set). Please enforce mutual exclusivity (e.g., validate in the action handler and throw a clear error when both are set).
src/commands/add.ts
Outdated
| const addOptions: AddOptions = { | ||
| ...addOptionsFromCli, | ||
| filePath: path, | ||
| ...(dataset && { datasetId: parseInt(dataset, 10) }), |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseInt(dataset, 10) is used without validation. If the user passes a non-integer (e.g., "abc" or "123x"), this can yield NaN or a surprising value and the flag will be silently ignored downstream. Please validate that the parsed ID is a positive safe integer and surface a helpful error when invalid.
| const addOptions: AddOptions = { | |
| ...addOptionsFromCli, | |
| filePath: path, | |
| ...(dataset && { datasetId: parseInt(dataset, 10) }), | |
| let datasetId: number | undefined | |
| if (dataset !== undefined) { | |
| const trimmed = String(dataset).trim() | |
| // Ensure the dataset ID is a positive safe integer and fully numeric | |
| if (!/^[0-9]+$/.test(trimmed)) { | |
| console.error(`Invalid value for --dataset: "${dataset}". Expected a positive integer ID.`) | |
| process.exit(1) | |
| } | |
| const parsed = Number(trimmed) | |
| if (!Number.isSafeInteger(parsed) || parsed <= 0) { | |
| console.error(`Invalid value for --dataset: "${dataset}". Expected a positive safe integer ID.`) | |
| process.exit(1) | |
| } | |
| datasetId = parsed | |
| } | |
| const addOptions: AddOptions = { | |
| ...addOptionsFromCli, | |
| filePath: path, | |
| ...(datasetId !== undefined && { datasetId }), |
| logger: expect.anything(), | ||
| }) | ||
| ) | ||
| }) |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The earlier metadata test now only asserts initializeSynapse/createStorageContext and no longer verifies that metadata is forwarded into the upload call (e.g., via performUpload). Either restore the upload-side assertion or adjust the test description/expectations so it matches the behavior being verified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beck-8 can you ensure we don't remove the metadata assertion
SgtPooki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, but one callout:
naming conventions are DataSet is two separate words, so we should stick to that, or add an alias at the very least. dataSet or data-set over dataset, but we have an alias in other places, so I'm good with dataset as long as we also have data-set in the CLI.
vars internally should use camelCase
d66111a to
3631fa0
Compare
SgtPooki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the quick updates @beck-8.. a few last things
| logger: expect.anything(), | ||
| }) | ||
| ) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beck-8 can you ensure we don't remove the metadata assertion
| // Add data set selection options | ||
| addCommand.addOption(new Option('--data-set <id>', 'ID of the existing data set to use')) | ||
| addCommand.addOption(new Option('--new-data-set', 'Create a new data set instead of using an existing one')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if this solves the mutual exclusivity problem brought up by a different copilot comment. you will want .conflicts('otherOption') for these
No description provided.