Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,72 +46,64 @@ ILogger<ICommandHandler<DataDictionaryCommandHandlerOptions>> logger
/// <returns>The data-dictionary command.</returns>
public static Command SetupCommand(IHost host)
{
var projectPathOption = new Option<DirectoryInfo>(
aliases: ["--project", "-p"],
description: "The path to the GenAI Database Explorer project."
)
var projectPathOption = new Option<DirectoryInfo>("--project", "-p")
{
IsRequired = true
Description = "The path to the GenAI Database Explorer project.",
Required = true
};

var sourcePathOption = new Option<string>(
aliases: ["--source-path", "-d"],
description: "The path to the source directory containing data dictionary files. Supports file masks."
)
var sourcePathOption = new Option<string>("--source-path", "-d")
{
IsRequired = true
Description = "The path to the source directory containing data dictionary files. Supports file masks.",
Required = true
};

var schemaNameOption = new Option<string>(
aliases: ["--schema", "-s"],
description: "The schema name of the object to process."
)
var schemaNameOption = new Option<string>("--schema", "-s")
{
ArgumentHelpName = "schemaName"
Description = "The schema name of the object to process.",
HelpName = "schemaName"
};

var nameOption = new Option<string>(
aliases: ["--name", "-n"],
description: "The name of the object to process."
)
var nameOption = new Option<string>("--name", "-n")
{
ArgumentHelpName = "name"
Description = "The name of the object to process.",
HelpName = "name"
};

var showOption = new Option<bool>(
aliases: ["--show"],
description: "Display the entity after processing.",
getDefaultValue: () => false
);

var dataDictionaryCommand = new Command("data-dictionary", "Process data dictionary files and update the semantic model.")
var showOption = new Option<bool>("--show")
{
projectPathOption
Description = "Display the entity after processing."
};

var tableCommand = new Command("table", "Process table data dictionary files.")
{
projectPathOption,
sourcePathOption,
schemaNameOption,
nameOption,
showOption
};
tableCommand.SetHandler(async (DirectoryInfo projectPath, string sourcePathPattern, string schemaName, string name, bool show) =>
var dataDictionaryCommand = new Command("data-dictionary", "Process data dictionary files and update the semantic model.");
dataDictionaryCommand.Options.Add(projectPathOption);

var tableCommand = new Command("table", "Process table data dictionary files.");
tableCommand.Options.Add(projectPathOption);
tableCommand.Options.Add(sourcePathOption);
tableCommand.Options.Add(schemaNameOption);
tableCommand.Options.Add(nameOption);
tableCommand.Options.Add(showOption);
tableCommand.SetAction((ParseResult parseResult) =>
{
var projectPath = parseResult.GetValue(projectPathOption);
var sourcePathPattern = parseResult.GetValue(sourcePathOption);
var schemaName = parseResult.GetValue(schemaNameOption);
var name = parseResult.GetValue(nameOption);
var show = parseResult.GetValue(showOption);
var handler = host.Services.GetRequiredService<DataDictionaryCommandHandler>();
var options = new DataDictionaryCommandHandlerOptions(
projectPath,
sourcePathPattern,
projectPath!,
sourcePathPattern!,
objectType: "table",
schemaName: schemaName,
objectName: name,
schemaName: schemaName!,
objectName: name!,
show: show
);
await handler.HandleAsync(options);
}, projectPathOption, sourcePathOption, schemaNameOption, nameOption, showOption);
return handler.HandleAsync(options);
});

dataDictionaryCommand.AddCommand(tableCommand);
dataDictionaryCommand.Subcommands.Add(tableCommand);

return dataDictionaryCommand;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,145 +40,143 @@ ILogger<ICommandHandler<EnrichModelCommandHandlerOptions>> logger
/// <returns>The enrich-model command.</returns>
public static Command SetupCommand(IHost host)
{
var projectPathOption = new Option<DirectoryInfo>(
aliases: ["--project", "-p"],
description: "The path to the GenAI Database Explorer project."
)
var projectPathOption = new Option<DirectoryInfo>("--project", "-p")
{
IsRequired = true
Description = "The path to the GenAI Database Explorer project.",
Required = true
};

var skipTablesOption = new Option<bool>(
aliases: ["--skipTables"],
description: "Flag to skip tables during the semantic model enrichment process.",
getDefaultValue: () => false
);

var skipViewsOption = new Option<bool>(
aliases: ["--skipViews"],
description: "Flag to skip views during the semantic model enrichment process.",
getDefaultValue: () => false
);

var skipStoredProceduresOption = new Option<bool>(
aliases: ["--skipStoredProcedures"],
description: "Flag to skip stored procedures during the semantic model enrichment process.",
getDefaultValue: () => false
);
var skipTablesOption = new Option<bool>("--skipTables")
{
Description = "Flag to skip tables during the semantic model enrichment process."
};

var schemaNameOption = new Option<string>(
aliases: ["--schema", "-s"],
description: "The schema name of the object to enrich."
)
var skipViewsOption = new Option<bool>("--skipViews")
{
ArgumentHelpName = "schemaName"
Description = "Flag to skip views during the semantic model enrichment process."
};

var nameOption = new Option<string>(
aliases: ["--name", "-n"],
description: "The name of the object to enrich."
)
var skipStoredProceduresOption = new Option<bool>("--skipStoredProcedures")
{
ArgumentHelpName = "name"
Description = "Flag to skip stored procedures during the semantic model enrichment process."
};

var showOption = new Option<bool>(
aliases: ["--show"],
description: "Display the entity after enrichment.",
getDefaultValue: () => false
);
var schemaNameOption = new Option<string>("--schema", "-s")
{
Description = "The schema name of the object to enrich.",
HelpName = "schemaName"
};

// Create the base 'enrich-model' command
var enrichModelCommand = new Command("enrich-model", "Enrich an existing semantic model with descriptions in a GenAI Database Explorer project.")
var nameOption = new Option<string>("--name", "-n")
{
projectPathOption,
skipTablesOption,
skipViewsOption,
skipStoredProceduresOption
Description = "The name of the object to enrich.",
HelpName = "name"
};

// Create subcommands
var tableCommand = new Command("table", "Enrich a specific table.")
var showOption = new Option<bool>("--show")
{
projectPathOption,
schemaNameOption,
nameOption,
showOption
Description = "Display the entity after enrichment."
};
tableCommand.SetHandler(async (DirectoryInfo projectPath, string schemaName, string name, bool show) =>

// Create the base 'enrich-model' command
var enrichModelCommand = new Command("enrich-model", "Enrich an existing semantic model with descriptions in a GenAI Database Explorer project.");
enrichModelCommand.Options.Add(projectPathOption);
enrichModelCommand.Options.Add(skipTablesOption);
enrichModelCommand.Options.Add(skipViewsOption);
enrichModelCommand.Options.Add(skipStoredProceduresOption);

// Create subcommands
var tableCommand = new Command("table", "Enrich a specific table.");
tableCommand.Options.Add(projectPathOption);
tableCommand.Options.Add(schemaNameOption);
tableCommand.Options.Add(nameOption);
tableCommand.Options.Add(showOption);
tableCommand.SetAction((ParseResult parseResult) =>
{
var projectPath = parseResult.GetValue(projectPathOption);
var schemaName = parseResult.GetValue(schemaNameOption);
var name = parseResult.GetValue(nameOption);
var show = parseResult.GetValue(showOption);
var handler = host.Services.GetRequiredService<EnrichModelCommandHandler>();
var options = new EnrichModelCommandHandlerOptions(
projectPath,
projectPath!,
skipTables: false,
skipViews: true,
skipStoredProcedures: true,
objectType: "table",
schemaName,
objectName: name,
schemaName!,
objectName: name!,
show: show
);
await handler.HandleAsync(options);
}, projectPathOption, schemaNameOption, nameOption, showOption);
return handler.HandleAsync(options);
});

var viewCommand = new Command("view", "Enrich a specific view.")
{
projectPathOption,
schemaNameOption,
nameOption,
showOption
};
viewCommand.SetHandler(async (DirectoryInfo projectPath, string schemaName, string name, bool show) =>
var viewCommand = new Command("view", "Enrich a specific view.");
viewCommand.Options.Add(projectPathOption);
viewCommand.Options.Add(schemaNameOption);
viewCommand.Options.Add(nameOption);
viewCommand.Options.Add(showOption);
viewCommand.SetAction((ParseResult parseResult) =>
{
var projectPath = parseResult.GetValue(projectPathOption);
var schemaName = parseResult.GetValue(schemaNameOption);
var name = parseResult.GetValue(nameOption);
var show = parseResult.GetValue(showOption);
var handler = host.Services.GetRequiredService<EnrichModelCommandHandler>();
var options = new EnrichModelCommandHandlerOptions(
projectPath,
projectPath!,
skipTables: true,
skipViews: false,
skipStoredProcedures: true,
objectType: "view",
schemaName,
objectName: name,
schemaName!,
objectName: name!,
show: show
);
await handler.HandleAsync(options);
}, projectPathOption, schemaNameOption, nameOption, showOption);
return handler.HandleAsync(options);
});

var storedProcedureCommand = new Command("storedprocedure", "Enrich a specific stored procedure.")
{
projectPathOption,
schemaNameOption,
nameOption,
showOption
};
storedProcedureCommand.SetHandler(async (DirectoryInfo projectPath, string schemaName, string name, bool show) =>
var storedProcedureCommand = new Command("storedprocedure", "Enrich a specific stored procedure.");
storedProcedureCommand.Options.Add(projectPathOption);
storedProcedureCommand.Options.Add(schemaNameOption);
storedProcedureCommand.Options.Add(nameOption);
storedProcedureCommand.Options.Add(showOption);
storedProcedureCommand.SetAction((ParseResult parseResult) =>
{
var projectPath = parseResult.GetValue(projectPathOption);
var schemaName = parseResult.GetValue(schemaNameOption);
var name = parseResult.GetValue(nameOption);
var show = parseResult.GetValue(showOption);
var handler = host.Services.GetRequiredService<EnrichModelCommandHandler>();
var options = new EnrichModelCommandHandlerOptions(
projectPath,
projectPath!,
skipTables: true,
skipViews: true,
skipStoredProcedures: false,
objectType: "storedprocedure",
schemaName,
objectName: name,
schemaName!,
objectName: name!,
show: show
);
await handler.HandleAsync(options);
}, projectPathOption, schemaNameOption, nameOption, showOption);
return handler.HandleAsync(options);
});

// Add subcommands to the 'enrich-model' command
enrichModelCommand.AddCommand(tableCommand);
enrichModelCommand.AddCommand(viewCommand);
enrichModelCommand.AddCommand(storedProcedureCommand);
enrichModelCommand.Subcommands.Add(tableCommand);
enrichModelCommand.Subcommands.Add(viewCommand);
enrichModelCommand.Subcommands.Add(storedProcedureCommand);

// Set default handler if no subcommand is provided
enrichModelCommand.SetHandler(async (DirectoryInfo projectPath, bool skipTables, bool skipViews, bool skipStoredProcedures) =>
enrichModelCommand.SetAction((ParseResult parseResult) =>
{
var projectPath = parseResult.GetValue(projectPathOption);
var skipTables = parseResult.GetValue(skipTablesOption);
var skipViews = parseResult.GetValue(skipViewsOption);
var skipStoredProcedures = parseResult.GetValue(skipStoredProceduresOption);
var handler = host.Services.GetRequiredService<EnrichModelCommandHandler>();
var options = new EnrichModelCommandHandlerOptions(projectPath, skipTables, skipViews, skipStoredProcedures);
await handler.HandleAsync(options);
}, projectPathOption, skipTablesOption, skipViewsOption, skipStoredProceduresOption);
var options = new EnrichModelCommandHandlerOptions(projectPath!, skipTables, skipViews, skipStoredProcedures);
return handler.HandleAsync(options);
});

return enrichModelCommand;
}
Expand Down
Loading