mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 01:08:18 +08:00
[PTRun][Program]Run commands: Support for MSC and CPL (#23668)
* code changes * spell fix * dev docs * update tests * Code improvement
This commit is contained in:
parent
00e10d38c2
commit
e4e1b5b43d
@ -42,3 +42,6 @@ There are broadly two different categories of applications:
|
||||
### Additional Notes
|
||||
- Arguments can be provided to the program plugin by entering them after `--` (a double dash).
|
||||
- The localization is done using the `Localization Helper`from `Wox.Plugin.Common` hosted at runtime in a variable of plugin's main class.
|
||||
- The `Run commands` differ in two points from the normal `Win32Programs`:
|
||||
- The result title contains the executable type.
|
||||
- The file types `.cpl` and `.msc` are supported too.
|
||||
|
@ -592,12 +592,27 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
var mock = new Mock<IPublicAPI>();
|
||||
StringMatcher.Instance = new StringMatcher();
|
||||
|
||||
// Act
|
||||
var result = _chrome.Result("chrome", string.Empty, mock.Object);
|
||||
|
||||
// Assert
|
||||
// Using Ordinal since this is used internally
|
||||
Assert.IsTrue(result.Title.Equals(_chrome.Name, StringComparison.Ordinal));
|
||||
Assert.IsFalse(result.Title.Equals(_chrome.Description, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RunCommandsShouldSetExecutableNameAsTitleWhileCreatingResult()
|
||||
{
|
||||
var mock = new Mock<IPublicAPI>();
|
||||
StringMatcher.Instance = new StringMatcher();
|
||||
|
||||
// Act
|
||||
var result = _cmderRunCommand.Result("cmder", string.Empty, mock.Object);
|
||||
|
||||
// Assert
|
||||
// Using Ordinal since this is used internally
|
||||
Assert.IsTrue(result.Title.Equals(_cmderRunCommand.Name, StringComparison.Ordinal));
|
||||
Assert.IsTrue(result.Title.Equals(_cmderRunCommand.ExecutableName, StringComparison.Ordinal));
|
||||
Assert.IsFalse(result.Title.Equals(_cmderRunCommand.Description, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace Microsoft.Plugin.Program
|
||||
|
||||
public List<string> ProgramSuffixes { get; set; } = new List<string>() { "bat", "appref-ms", "exe", "lnk", "url" };
|
||||
|
||||
public List<string> RunCommandSuffixes { get; set; } = new List<string>() { "bat", "appref-ms", "exe", "lnk", "url", "cpl", "msc" };
|
||||
|
||||
public bool EnableStartMenuSource { get; set; } = true;
|
||||
|
||||
public bool EnableDesktopSource { get; set; } = true;
|
||||
|
@ -91,7 +91,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
private const string ShortcutExtension = "lnk";
|
||||
private const string ApplicationReferenceExtension = "appref-ms";
|
||||
private const string InternetShortcutExtension = "url";
|
||||
private static readonly HashSet<string> ExecutableApplicationExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "exe", "bat", "bin", "com", "msc", "msi", "cmd", "ps1", "job", "msp", "mst", "sct", "ws", "wsh", "wsf" };
|
||||
private static readonly HashSet<string> ExecutableApplicationExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "exe", "bat", "bin", "com", "cpl", "msc", "msi", "cmd", "ps1", "job", "msp", "mst", "sct", "ws", "wsh", "wsf" };
|
||||
|
||||
private const string ProxyWebApp = "_proxy.exe";
|
||||
private const string AppIdArgument = "--app-id";
|
||||
@ -255,6 +255,12 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
},
|
||||
};
|
||||
|
||||
// Adjust title of RunCommand result
|
||||
if (AppType == ApplicationType.RunCommand)
|
||||
{
|
||||
result.Title = ExecutableName;
|
||||
}
|
||||
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, result.Title).MatchData;
|
||||
|
||||
// Using CurrentCulture since this is user facing
|
||||
@ -1005,7 +1011,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
// Run commands are always set as AppType "RunCommand"
|
||||
var runCommandSources = new (bool IsEnabled, Func<IEnumerable<string>> GetPaths)[]
|
||||
{
|
||||
(settings.EnablePathEnvironmentVariableSource, () => PathEnvironmentProgramPaths(settings.ProgramSuffixes)),
|
||||
(settings.EnablePathEnvironmentVariableSource, () => PathEnvironmentProgramPaths(settings.RunCommandSuffixes)),
|
||||
};
|
||||
|
||||
var disabledProgramsList = settings.DisabledProgramSources;
|
||||
|
Loading…
Reference in New Issue
Block a user