-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMapsCommand.cs
More file actions
31 lines (30 loc) · 1.1 KB
/
MapsCommand.cs
File metadata and controls
31 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.CommandLine;
using SchemaScraper.Cli;
using SchemaScraper.Models;
using SchemaScraper.Services;
using SchemaScraper.Sql;
namespace SchemaScraper.Commands;
public class MapsCommand()
: ConnectorCommand(
"maps",
"Scrape and output recursive relationship maps for a table.",
new Func<string, string?, string?, string?, FileInfo, Task>(Call),
[
new Option<string>(
aliases: ["--table", "-t"],
description: "SQL database table."
)
]
)
{
static async Task Call(string table, string? key, string? server, string? db, FileInfo connections)
{
Connector connector = Connector.Generate(key, server, db, connections);
ScraperQuery query = new(connector);
List<ScraperTable> dependencyMap = await query.MapDependencies(table);
List<ScraperTable> dependentMap = await query.MapDependents(table);
Console.WriteLine("Table, IsDependency");
dependencyMap.ForEach(x => Console.WriteLine($"{x}, {true}"));
dependentMap.ForEach(x => Console.WriteLine($"{x}, {false}"));
}
}