mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
PluginsManager: refactor sub-commands
Rename them to something more accurate, switch them to be const
This commit is contained in:
parent
d6bca894ff
commit
a0bb995643
3 changed files with 17 additions and 20 deletions
|
|
@ -50,15 +50,12 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
||||||
if (string.IsNullOrWhiteSpace(query.Search))
|
if (string.IsNullOrWhiteSpace(query.Search))
|
||||||
return pluginManager.GetDefaultHotKeys();
|
return pluginManager.GetDefaultHotKeys();
|
||||||
|
|
||||||
return query.FirstSearch switch
|
return query.FirstSearch.ToLower() switch
|
||||||
{
|
{
|
||||||
//search could be url, no need ToLower() when passed in
|
//search could be url, no need ToLower() when passed in
|
||||||
var s when s.Equals(Settings.HotKeyInstall, StringComparison.OrdinalIgnoreCase)
|
Settings.InstallCommand => await pluginManager.RequestInstallOrUpdate(query.SecondToEndSearch, token),
|
||||||
=> await pluginManager.RequestInstallOrUpdate(query.SecondToEndSearch, token),
|
Settings.UninstallCommand => pluginManager.RequestUninstall(query.SecondToEndSearch),
|
||||||
var s when s.Equals(Settings.HotkeyUninstall, StringComparison.OrdinalIgnoreCase)
|
Settings.UpdateCommand => await pluginManager.RequestUpdate(query.SecondToEndSearch, token),
|
||||||
=> pluginManager.RequestUninstall(query.SecondToEndSearch),
|
|
||||||
var s when s.Equals(Settings.HotkeyUpdate, StringComparison.OrdinalIgnoreCase)
|
|
||||||
=> await pluginManager.RequestUpdate(query.SecondToEndSearch, token),
|
|
||||||
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
|
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
|
||||||
{
|
{
|
||||||
hotkey.Score = StringMatcher.FuzzySearch(query.Search, hotkey.Title).Score;
|
hotkey.Score = StringMatcher.FuzzySearch(query.Search, hotkey.Title).Score;
|
||||||
|
|
|
||||||
|
|
@ -75,34 +75,34 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
||||||
{
|
{
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = Settings.HotKeyInstall,
|
Title = Settings.InstallCommand,
|
||||||
IcoPath = icoPath,
|
IcoPath = icoPath,
|
||||||
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotKeyInstall} ",
|
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.InstallCommand} ",
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotKeyInstall} ");
|
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.InstallCommand} ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = Settings.HotkeyUninstall,
|
Title = Settings.UninstallCommand,
|
||||||
IcoPath = icoPath,
|
IcoPath = icoPath,
|
||||||
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotkeyUninstall} ",
|
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UninstallCommand} ",
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotkeyUninstall} ");
|
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UninstallCommand} ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Result()
|
new Result()
|
||||||
{
|
{
|
||||||
Title = Settings.HotkeyUpdate,
|
Title = Settings.UpdateCommand,
|
||||||
IcoPath = icoPath,
|
IcoPath = icoPath,
|
||||||
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotkeyUpdate} ",
|
AutoCompleteText = $"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UpdateCommand} ",
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.HotkeyUpdate} ");
|
Context.API.ChangeQuery($"{Context.CurrentPluginMetadata.ActionKeyword} {Settings.UpdateCommand} ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
||||||
Context
|
Context
|
||||||
.API
|
.API
|
||||||
.ChangeQuery(
|
.ChangeQuery(
|
||||||
$"{Context.CurrentPluginMetadata.ActionKeywords.FirstOrDefault()} {Settings.HotkeyUpdate} {plugin.Name}");
|
$"{Context.CurrentPluginMetadata.ActionKeywords.FirstOrDefault()} {Settings.UpdateCommand} {plugin.Name}");
|
||||||
|
|
||||||
var mainWindow = Application.Current.MainWindow;
|
var mainWindow = Application.Current.MainWindow;
|
||||||
mainWindow.Show();
|
mainWindow.Show();
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
||||||
{
|
{
|
||||||
internal class Settings
|
internal class Settings
|
||||||
{
|
{
|
||||||
internal string HotKeyInstall { get; set; } = "install";
|
internal const string InstallCommand = "install";
|
||||||
|
|
||||||
internal string HotkeyUninstall { get; set; } = "uninstall";
|
internal const string UninstallCommand = "uninstall";
|
||||||
|
|
||||||
internal string HotkeyUpdate { get; set; } = "update";
|
internal const string UpdateCommand = "update";
|
||||||
|
|
||||||
public bool WarnFromUnknownSource { get; set; } = true;
|
public bool WarnFromUnknownSource { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue