Skip to content

Commit

Permalink
fix(配置文件): 增加空白符处理
Browse files Browse the repository at this point in the history
  • Loading branch information
yukinotech committed May 26, 2022
1 parent 38e392f commit fb06e53
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion BBDown/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,17 @@ public static async Task<int> Main(params string[] args)
var configArgs = File
.ReadAllLines(configPath)
.Where(s => !string.IsNullOrEmpty(s) && !s.StartsWith("#"))
.SelectMany(s => s.Split(' ').Where(s => !string.IsNullOrEmpty(s)).Select(s => s.Trim('\"')));
.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)
{
Expand Down

0 comments on commit fb06e53

Please sign in to comment.