in src/ApiPort/ApiPort/CommandLineOptions.cs [19:120]
public static ICommandLineOptions ParseCommandLineOptions(string[] args)
{
bool overwriteOutput = false;
IReadOnlyList<string> file = Array.Empty<string>();
string outFile = DefaultName;
string description = string.Empty;
string entrypoint = string.Empty;
IReadOnlyList<string> target = Array.Empty<string>();
IReadOnlyList<string> result = Array.Empty<string>();
bool showNonPortableApis = true;
bool showBreakingChanges = false;
bool showRetargettingIssues = false;
bool showExceptionApis = false;
bool noDefaultIgnoreFile = false;
IReadOnlyList<string> ignoreAssemblyFile = Array.Empty<string>();
IReadOnlyList<string> suppressBreakingChange = Array.Empty<string>();
string targetMap = string.Empty;
string endpoint = "https://portability.dot.net";
AppCommand command = default;
ArgumentSyntax argSyntax = default;
try
{
ArgumentSyntax.Parse(args, syntax =>
{
syntax.HandleErrors = false;
syntax.DefineCommand("analyze", ref command, AppCommand.AnalyzeAssemblies, LocalizedStrings.CmdAnalyzeMessage);
syntax.DefineOptionList("f|file", ref file, LocalizedStrings.CmdAnalyzeFileInput);
syntax.DefineOption("o|out", ref outFile, LocalizedStrings.CmdAnalyzeOutputFileName);
syntax.DefineOption("d|description", ref description, LocalizedStrings.CmdAnalyzeDescription);
syntax.DefineOption("e|endpoint", ref endpoint, LocalizedStrings.CmdEndpoint);
syntax.DefineOption("entrypoint", ref entrypoint, LocalizedStrings.CmdEntrypoint);
syntax.DefineOptionList("t|target", ref target, LocalizedStrings.CmdAnalyzeTarget);
syntax.DefineOptionList("r|resultFormat", ref result, LocalizedStrings.CmdAnalyzeResultFormat);
syntax.DefineOption("p|showNonPortableApis", ref showNonPortableApis, LocalizedStrings.CmdAnalyzeShowNonPortableApis);
syntax.DefineOption("b|showBreakingChanges", ref showBreakingChanges, LocalizedStrings.CmdAnalyzeShowBreakingChanges);
syntax.DefineOption("u|showRetargettingIssues", ref showRetargettingIssues, LocalizedStrings.CmdAnalyzeShowRetargettingIssues);
syntax.DefineOption("x|showExceptionApis", ref showExceptionApis, LocalizedStrings.CmdAnalyzeShowExceptionApis);
syntax.DefineOption("force", ref overwriteOutput, LocalizedStrings.OverwriteFile);
syntax.DefineOption("noDefaultIgnoreFile", ref noDefaultIgnoreFile, LocalizedStrings.CmdAnalyzeNoDefaultIgnoreFile);
syntax.DefineOptionList("i|ignoreAssemblyFile", ref ignoreAssemblyFile, LocalizedStrings.CmdAnalyzeIgnoreAssembliesFile);
syntax.DefineOptionList("s|suppressBreakingChange", ref suppressBreakingChange, LocalizedStrings.CmdAnalyzeSuppressBreakingChange);
syntax.DefineOption("targetMap", ref targetMap, LocalizedStrings.CmdAnalyzeTargetMap);
#if !FEATURE_OFFLINE
syntax.DefineCommand("dump", ref command, AppCommand.DumpAnalysis, LocalizedStrings.CmdDumpAnalysis);
syntax.DefineOptionList("f|file", ref file, LocalizedStrings.CmdAnalyzeFileInput);
syntax.DefineOption("o|out", ref outFile, LocalizedStrings.CmdAnalyzeOutputFileName);
#endif
syntax.DefineCommand("listTargets", ref command, AppCommand.ListTargets, LocalizedStrings.ListTargets);
syntax.DefineOption("e|endpoint", ref endpoint, LocalizedStrings.CmdEndpoint);
syntax.DefineCommand("listOutputFormats", ref command, AppCommand.ListOutputFormats, LocalizedStrings.ListOutputFormats);
syntax.DefineOption("e|endpoint", ref endpoint, LocalizedStrings.CmdEndpoint);
syntax.DefineCommand("docId", ref command, AppCommand.DocIdSearch, LocalizedStrings.CmdDocId);
syntax.DefineOption("e|endpoint", ref endpoint, LocalizedStrings.CmdEndpoint);
argSyntax = syntax;
});
}
catch (ArgumentSyntaxException e)
{
Console.WriteLine();
Console.WriteLine(e.Message);
if (argSyntax != null)
{
Console.WriteLine(argSyntax.GetHelpText());
}
return new ConsoleApiPortOptions(AppCommand.Exit);
}
// Set OverwriteOutputFile to true if the output file name is explicitly specified
if (!string.Equals(DefaultName, outFile, StringComparison.Ordinal))
{
overwriteOutput = true;
}
var (inputFiles, invalidFiles) = ProcessInputAssemblies(file);
return new ConsoleApiPortOptions(command)
{
BreakingChangeSuppressions = suppressBreakingChange,
Description = description,
Entrypoint = entrypoint,
IgnoredAssemblyFiles = ignoreAssemblyFile,
InputAssemblies = inputFiles,
InvalidInputFiles = invalidFiles,
OutputFileName = outFile,
OutputFormats = result,
OverwriteOutputFile = overwriteOutput,
RequestFlags = GetRequestFlags(showBreakingChanges, showRetargettingIssues, showNonPortableApis, showExceptionApis),
ServiceEndpoint = endpoint,
TargetMapFile = targetMap,
Targets = target,
};
}