【特性】新增 --output:tables, --output:include_tables, --output:exclude_tables 用于指定包含或者排除某些表

main
walon 2021-12-18 18:50:03 +08:00
parent 6bc3552a1f
commit c2fc86215c
2 changed files with 59 additions and 1 deletions

View File

@ -70,6 +70,12 @@ namespace Luban.Job.Cfg.Defs
public bool NeedL10nTextTranslate => ExportTextTable != null; public bool NeedL10nTextTranslate => ExportTextTable != null;
private HashSet<string> _overrideOutputTables;
private readonly HashSet<string> _outputIncludeTables = new();
private readonly HashSet<string> _outputExcludeTables = new();
public void InitL10n(string textValueFieldName) public void InitL10n(string textValueFieldName)
{ {
ExportTextTable = new TextTable(this, textValueFieldName); ExportTextTable = new TextTable(this, textValueFieldName);
@ -161,7 +167,10 @@ namespace Luban.Job.Cfg.Defs
public List<DefTable> GetExportTables() public List<DefTable> GetExportTables()
{ {
return Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); return Types.Values.Where(t => t is DefTable ct
&& !_outputExcludeTables.Contains(t.FullName)
&& (_outputIncludeTables.Contains(t.FullName) || (_overrideOutputTables == null ? ct.NeedExport : _overrideOutputTables.Contains(ct.FullName)))
).Select(t => (DefTable)t).ToList();
} }
public List<DefTypeBase> GetExportTypes() public List<DefTypeBase> GetExportTypes()
@ -210,6 +219,11 @@ namespace Luban.Job.Cfg.Defs
return _refGroups.TryGetValue(groupName, out var refGroup) ? refGroup : null; return _refGroups.TryGetValue(groupName, out var refGroup) ? refGroup : null;
} }
private IEnumerable<string> SplitTableList(string tables)
{
return tables.Split(',').Select(t => t.Trim());
}
public void Load(Defines defines, IAgent agent, GenArgs args) public void Load(Defines defines, IAgent agent, GenArgs args)
{ {
LoadCommon(defines, agent, args); LoadCommon(defines, agent, args);
@ -258,6 +272,41 @@ namespace Luban.Job.Cfg.Defs
AddCfgTable(table); AddCfgTable(table);
} }
if (!string.IsNullOrWhiteSpace(args.OutputTables))
{
foreach (var tableFullName in SplitTableList(args.OutputTables))
{
if (GetCfgTable(tableFullName) == null)
{
throw new Exception($"--output:tables 参数中 table:'{tableFullName}' 不存在");
}
_overrideOutputTables ??= new HashSet<string>();
_overrideOutputTables.Add(tableFullName);
}
}
if (!string.IsNullOrWhiteSpace(args.OutputIncludeTables))
{
foreach (var tableFullName in SplitTableList(args.OutputIncludeTables))
{
if (GetCfgTable(tableFullName) == null)
{
throw new Exception($"--output:include_tables 参数中 table:'{tableFullName}' 不存在");
}
_outputIncludeTables.Add(tableFullName);
}
}
if (!string.IsNullOrWhiteSpace(args.OutputExcludeTables))
{
foreach (var tableFullName in SplitTableList(args.OutputExcludeTables))
{
if (GetCfgTable(tableFullName) == null)
{
throw new Exception($"--output:exclude_tables 参数中 table:'{tableFullName}' 不存在");
}
_outputExcludeTables.Add(tableFullName);
}
}
_cfgServices.AddRange(defines.Services); _cfgServices.AddRange(defines.Services);
foreach (var type in Types.Values) foreach (var type in Types.Values)

View File

@ -23,6 +23,15 @@ namespace Luban.Job.Cfg
[Option("input:convert_data_dir", Required = false, HelpText = "override input data dir with convert data dir")] [Option("input:convert_data_dir", Required = false, HelpText = "override input data dir with convert data dir")]
public string InputConvertDataDir { get; set; } public string InputConvertDataDir { get; set; }
[Option("output:tables", Required = false, HelpText = "override tables in export group with this list")]
public string OutputTables { get; set; }
[Option("output:include_tables", Required = false, HelpText = "include tables")]
public string OutputIncludeTables { get; set; }
[Option("output:exclude_tables", Required = false, HelpText = "exclude tables")]
public string OutputExcludeTables { get; set; }
[Option("output:data:resource_list_file", Required = false, HelpText = "output resource list file")] [Option("output:data:resource_list_file", Required = false, HelpText = "output resource list file")]
public string OutputDataResourceListFile { get; set; } public string OutputDataResourceListFile { get; set; }