Skip to content

Add dab auto-config-simulate CLI command#3189

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-cli-command-auto-config-simulate
Draft

Add dab auto-config-simulate CLI command#3189
Copilot wants to merge 4 commits intomainfrom
copilot/add-cli-command-auto-config-simulate

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Why make this change?

Developers using autoentities needed a way to preview which database objects would be matched by their filter definitions before committing changes to the config.

What is this change?

New autoentities-simulate verb that connects to the MSSQL database, executes the autoentities pattern-match query for each filter definition, and outputs results.

New files:

  • src/Cli/Commands/AutoSimulateOptions.cs — defines the autoentities-simulate verb with optional --output/-o flag

ConfigGenerator.cs additions:

  • TrySimulateAutoentities — loads config (with env-var resolution), validates MSSQL + autoentities present, opens a SqlConnection, and runs MsSqlQueryBuilder.BuildGetAutoentitiesQuery() for each defined filter
  • WriteSimulationResultsToConsole — prints grouped output with match counts and aligned entity → schema.object lines
  • WriteSimulationResultsToCsvFile — writes RFC 4180-compliant CSV (values are properly quoted/escaped)
  • QuoteCsvValue — helper that wraps and escapes commas, quotes, and newlines in CSV fields

Program.cs: registers AutoSimulateOptions in the parser.

How was this tested?

  • Integration Tests
  • Unit Tests — AutoSimulateTests.cs covers: missing config, non-MSSQL database type, no autoentities defined, and options parsing.

Sample Request(s)

Console output (default):

dab autoentities-simulate
AutoEntities Simulation Results

Filter: ProductTables
Matches: 3

Products  -> dbo.Products
Inventory -> dbo.Inventory
Pricing   -> dbo.Pricing

Filter: AnotherFilter
Matches: 0

(no matches)

CSV file output:

dab autoentities-simulate --output results.csv
filter_name,entity_name,database_object
ProductTables,Products,dbo.Products
ProductTables,Inventory,dbo.Inventory
ProductTables,Pricing,dbo.Pricing
Original prompt

This section details on the original issue you should resolve

<issue_title>Add CLI command dab auto-config-simulate</issue_title>
<issue_description>New CLI commands need to be added in order to allow the users to change the autoentities properties inside of the config file.
Introduce a new autoentities configure subcommand that operates like an upsert.
These commands need to follow the existing coding pattern that we have for the other CLI commands

dab auto-config-simulate --output file.json

This command will output all of the existing entities that are created from the autoentities configuration

  • The output flag is optional, if it doesn’t appear then it will be output into the console
  • The things that will be outputed for each entity is the alias, definition-name, and object name
  • File output is csv
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@JerryNixon The purpose of `dab autoentities simulate` is to allow developers to see the result of their filters against the database.

Output to the console:

dab autoentities simulate

Output format

AutoEntities Simulation Results

Filter: <filter_name>
Matches: <count>

<entity_name> -> <schema_name>.<object_name>
<entity_name> -> <schema_name>.<object_name>
  • Output is grouped by filter.
  • If a filter has zero matches, output:
(no matches)

Output example

AutoEntities Simulation Results

Filter: ProductTables
Matches: 3

Products  -> dbo.Products
Inventory -> dbo.Inventory
Pricing   -> dbo.Pricing

Filter: AnotherFilter
Matches: 0

(no matches)

Output to a file:

dab autoentities simulate --output file.txt
  • If file name is invalid throw an exception
  • If file already exists overwrite it (no prompt)

Output format (CSV)

  • CSV includes a header row.
  • Each match is output as one CSV line.
filter_name,entity_name,database_object

Where database_object is <schema_name>.<object_name>.

Output example (CSV)

filter_name,entity_name,database_object
ProductTables,Products,dbo.Products
ProductTables,Inventory,dbo.Inventory
ProductTables,Pricing,dbo.Pricing
```</body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 3, 2026 19:29
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
…doc comment

Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CLI command dab auto-config-simulate Add dab autoentities-simulate CLI command Mar 3, 2026
@RubenCerna2079 RubenCerna2079 added this to the March 2026 milestone Mar 4, 2026
@RubenCerna2079 RubenCerna2079 changed the title Add dab autoentities-simulate CLI command Add dab auto-config-simulate CLI command Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Add CLI command dab auto-config-simulate

2 participants