mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[PowerToys Run] Plugins StyleCop and warnings fix (#12623)
This commit is contained in:
committed by
GitHub
parent
7ea1f26209
commit
1791246a79
@@ -1,4 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -7,8 +11,8 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
|
||||
{
|
||||
public class SshConfig
|
||||
{
|
||||
private static readonly Regex SSH_CONFIG = new Regex(@"^(\w[\s\S]*?\w)$(?=(?:\s+^\w|\z))", RegexOptions.Multiline);
|
||||
private static readonly Regex KEY_VALUE = new Regex(@"(\w+\s\S+)", RegexOptions.Multiline);
|
||||
private static readonly Regex _sshConfig = new Regex(@"^(\w[\s\S]*?\w)$(?=(?:\s+^\w|\z))", RegexOptions.Multiline);
|
||||
private static readonly Regex _keyValue = new Regex(@"(\w+\s\S+)", RegexOptions.Multiline);
|
||||
|
||||
public static IEnumerable<SshHost> ParseFile(string path)
|
||||
{
|
||||
@@ -17,23 +21,24 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
|
||||
|
||||
public static IEnumerable<SshHost> Parse(string str)
|
||||
{
|
||||
|
||||
str = str.Replace("\r", "");
|
||||
str = str.Replace('\r', '\0');
|
||||
var list = new List<SshHost>();
|
||||
foreach (Match match in SSH_CONFIG.Matches(str))
|
||||
foreach (Match match in _sshConfig.Matches(str))
|
||||
{
|
||||
var sshHost = new SshHost();
|
||||
string content = match.Groups.Values.ToList()[0].Value;
|
||||
foreach (Match match1 in KEY_VALUE.Matches(content))
|
||||
foreach (Match match1 in _keyValue.Matches(content))
|
||||
{
|
||||
var split = match1.Value.Split(" ");
|
||||
var key = split[0];
|
||||
var value = split[1];
|
||||
sshHost.Properties[key] = value;
|
||||
}
|
||||
|
||||
list.Add(sshHost);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
|
||||
{
|
||||
public class SshHost
|
||||
{
|
||||
public string IdentityFile
|
||||
public string IdentityFile
|
||||
{
|
||||
get => this[nameof(IdentityFile)]?.ToString();
|
||||
set => this[nameof(IdentityFile)] = value;
|
||||
}
|
||||
|
||||
public string Host
|
||||
public string Host
|
||||
{
|
||||
get => this[nameof(Host)]?.ToString();
|
||||
set => this[nameof(Host)] = value;
|
||||
}
|
||||
|
||||
public string HostName
|
||||
public string HostName
|
||||
{
|
||||
get => this[nameof(HostName)]?.ToString();
|
||||
set => this[nameof(HostName)] = value;
|
||||
}
|
||||
|
||||
public string User {
|
||||
public string User
|
||||
{
|
||||
get => this[nameof(User)]?.ToString();
|
||||
set => this[nameof(User)] = value;
|
||||
}
|
||||
|
||||
public string ForwardAgent {
|
||||
public string ForwardAgent
|
||||
{
|
||||
get => this[nameof(ForwardAgent)]?.ToString();
|
||||
set => this[nameof(ForwardAgent)] = value;
|
||||
}
|
||||
@@ -36,7 +42,7 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
|
||||
|
||||
public object this[string key]
|
||||
{
|
||||
get
|
||||
get
|
||||
{
|
||||
if (Properties.TryGetValue(key, out var value))
|
||||
{
|
||||
@@ -45,9 +51,13 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.SshConfigParser
|
||||
|
||||
return null;
|
||||
}
|
||||
set { Properties[key] = value; }
|
||||
|
||||
set
|
||||
{
|
||||
Properties[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Keys => Properties.Keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user