Reduce catalog to Phase 1 ACC/PROD view
This commit is contained in:
@@ -4,9 +4,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace BizTalkApplicationCatalog.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Validiert die Kommandozeile und stellt ausschließlich normalisierte Werte bereit.
|
||||
/// </summary>
|
||||
internal sealed class CommandLineOptions
|
||||
{
|
||||
private static readonly Regex UnsafeEnvironment =
|
||||
@@ -14,14 +11,12 @@ namespace BizTalkApplicationCatalog.Configuration
|
||||
|
||||
public string EnvironmentName { get; private set; }
|
||||
public string OutputDirectory { get; private set; }
|
||||
public string ManagementServer { get; private set; }
|
||||
public string ManagementDatabase { get; private set; }
|
||||
public string AccSnapshotPath { get; private set; }
|
||||
public string ProdSnapshotPath { get; private set; }
|
||||
public bool MergeMode { get; private set; }
|
||||
public bool SelfTest { get; private set; }
|
||||
public bool ShowHelp { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parst die Argumente. Unbekannte oder unvollständige Optionen werden abgelehnt.
|
||||
/// </summary>
|
||||
public static CommandLineOptions Parse(string[] args)
|
||||
{
|
||||
var result = new CommandLineOptions();
|
||||
@@ -36,11 +31,14 @@ namespace BizTalkApplicationCatalog.Configuration
|
||||
case "--output":
|
||||
result.OutputDirectory = Value(args, ref index, argument);
|
||||
break;
|
||||
case "--management-server":
|
||||
result.ManagementServer = Value(args, ref index, argument);
|
||||
case "--merge":
|
||||
result.MergeMode = true;
|
||||
break;
|
||||
case "--management-database":
|
||||
result.ManagementDatabase = Value(args, ref index, argument);
|
||||
case "--acc-json":
|
||||
result.AccSnapshotPath = Value(args, ref index, argument);
|
||||
break;
|
||||
case "--prod-json":
|
||||
result.ProdSnapshotPath = Value(args, ref index, argument);
|
||||
break;
|
||||
case "--self-test":
|
||||
result.SelfTest = true;
|
||||
@@ -55,31 +53,54 @@ namespace BizTalkApplicationCatalog.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
if (result.SelfTest || result.ShowHelp)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (result.SelfTest || result.ShowHelp) return result;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(result.EnvironmentName))
|
||||
if (result.MergeMode)
|
||||
{
|
||||
throw new ArgumentException("--environment fehlt.");
|
||||
if (!string.IsNullOrWhiteSpace(result.EnvironmentName))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"--environment darf nicht mit --merge kombiniert werden.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(result.AccSnapshotPath)
|
||||
|| string.IsNullOrWhiteSpace(result.ProdSnapshotPath))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"--merge benötigt --acc-json und --prod-json.");
|
||||
}
|
||||
result.AccSnapshotPath = FullPath(result.AccSnapshotPath);
|
||||
result.ProdSnapshotPath = FullPath(result.ProdSnapshotPath);
|
||||
}
|
||||
|
||||
result.EnvironmentName = UnsafeEnvironment.Replace(
|
||||
result.EnvironmentName.Trim().ToUpperInvariant(), "-").Trim('-');
|
||||
if (result.EnvironmentName.Length == 0)
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("--environment enthält keinen gültigen Namen.");
|
||||
if (!string.IsNullOrWhiteSpace(result.AccSnapshotPath)
|
||||
|| !string.IsNullOrWhiteSpace(result.ProdSnapshotPath))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"--acc-json und --prod-json sind nur mit --merge zulässig.");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(result.EnvironmentName))
|
||||
{
|
||||
throw new ArgumentException("--environment fehlt.");
|
||||
}
|
||||
result.EnvironmentName = UnsafeEnvironment.Replace(
|
||||
result.EnvironmentName.Trim().ToUpperInvariant(),
|
||||
"-").Trim('-');
|
||||
if (result.EnvironmentName != "ACC" && result.EnvironmentName != "PROD")
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"--environment muss ACC oder PROD sein.");
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(result.OutputDirectory))
|
||||
{
|
||||
result.OutputDirectory = Path.Combine(
|
||||
Environment.CurrentDirectory, "BizTalk-Anwendungsinventar", result.EnvironmentName);
|
||||
Environment.CurrentDirectory,
|
||||
"BizTalk-Anwendungskatalog",
|
||||
result.MergeMode ? "ACC-PROD" : result.EnvironmentName);
|
||||
}
|
||||
|
||||
result.OutputDirectory = Path.GetFullPath(
|
||||
Environment.ExpandEnvironmentVariables(result.OutputDirectory));
|
||||
result.OutputDirectory = FullPath(result.OutputDirectory);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -87,29 +108,40 @@ namespace BizTalkApplicationCatalog.Configuration
|
||||
{
|
||||
return string.Join(Environment.NewLine, new[]
|
||||
{
|
||||
"BEW BizTalk Application Catalog",
|
||||
"BEW BizTalk Application Catalog – Phase 1",
|
||||
string.Empty,
|
||||
"Aufruf:",
|
||||
" BizTalkApplicationCatalog.exe --environment ACC [--output PFAD]",
|
||||
" BizTalkApplicationCatalog.exe --environment PROD [--output PFAD]",
|
||||
"Lokalen Snapshot und lokale Excel-Sicht erzeugen:",
|
||||
" BizTalkApplicationCatalog.exe --environment ACC --output PFAD",
|
||||
" BizTalkApplicationCatalog.exe --environment PROD --output PFAD",
|
||||
string.Empty,
|
||||
"ACC und PROD zur gemeinsamen Excel-Sicht zusammenführen:",
|
||||
" BizTalkApplicationCatalog.exe --merge --acc-json ACC.json --prod-json PROD.json --output PFAD",
|
||||
string.Empty,
|
||||
"Optionen:",
|
||||
" --management-server NAME Optionaler SQL-Server-Hinweis.",
|
||||
" --management-database NAME Optionale Management-Datenbank.",
|
||||
" --self-test Prüft XLSX-Struktur und Kernlogik ohne BizTalk.",
|
||||
" --help Diese Hilfe."
|
||||
" --environment ACC|PROD Lokal zu inventarisierende Umgebung.",
|
||||
" --output PFAD Zielordner für XLSX, JSON und Log.",
|
||||
" --merge Führt zwei vollständige JSON-Snapshots zusammen.",
|
||||
" --acc-json PFAD Vollständiger ACC-Snapshot.",
|
||||
" --prod-json PFAD Vollständiger PROD-Snapshot.",
|
||||
" --self-test Prüft JSON, Merge und XLSX ohne BizTalk.",
|
||||
" --help Diese Hilfe."
|
||||
});
|
||||
}
|
||||
|
||||
private static string Value(string[] args, ref int index, string option)
|
||||
{
|
||||
index++;
|
||||
if (index >= args.Length || args[index].StartsWith("--", StringComparison.Ordinal))
|
||||
if (index >= args.Length
|
||||
|| args[index].StartsWith("--", StringComparison.Ordinal))
|
||||
{
|
||||
throw new ArgumentException("Wert für " + option + " fehlt.");
|
||||
}
|
||||
|
||||
return args[index];
|
||||
}
|
||||
|
||||
private static string FullPath(string value)
|
||||
{
|
||||
return Path.GetFullPath(Environment.ExpandEnvironmentVariables(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user