Skip to content

Commit

Permalink
Merge pull request #361 from yukinotech/master
Browse files Browse the repository at this point in the history
fix(配置文件): 修复配置文件无法正确读取string参数
nilaoda authored May 26, 2022
2 parents 7ad03d6 + fb06e53 commit 06ec6fe
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion BBDown/Program.cs
Original file line number Diff line number Diff line change
@@ -332,7 +332,20 @@ public static async Task<int> Main(params string[] args)
if (File.Exists(configPath))
{
Log($"加载配置文件: {configPath}");
var configArgs = File.ReadAllLines(configPath).Where(s => !string.IsNullOrEmpty(s) && !s.StartsWith("#")).Select(s => s.Trim().Trim('\"'));
var configArgs = File
.ReadAllLines(configPath)
.Where(s => !string.IsNullOrEmpty(s) && !s.StartsWith("#"))
.SelectMany(s => {
var trimLine = s.Trim();
if (trimLine.IndexOf('-') == 0 && trimLine.IndexOf(' ') != -1) {
var spaceIndex = trimLine.IndexOf(' ');
var paramsGroup = new String[] { trimLine.Substring(0,spaceIndex), trimLine.Substring(spaceIndex) };
return paramsGroup.Where(s => !string.IsNullOrEmpty(s)).Select(s => s.Trim(' ').Trim('\"'));
} else {
return new String[] {trimLine.Trim('\"')};
}
}
);
var configArgsResult = rootCommand.Parse(configArgs.ToArray());
foreach (var item in configArgsResult.CommandResult.Children)
{

0 comments on commit 06ec6fe

Please sign in to comment.