QuitAction.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using CommunityToolkit.Mvvm.Messaging;
 6  using Microsoft.CmdPal.UI.ViewModels.Messages;
 7  using Microsoft.CommandPalette.Extensions;
 8  using Microsoft.CommandPalette.Extensions.Toolkit;
 9  
10  namespace Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;
11  
12  public partial class QuitCommand : InvokableCommand, IFallbackHandler
13  {
14      public QuitCommand()
15      {
16          Id = "com.microsoft.cmdpal.quit";
17          Icon = new IconInfo("\uE711");
18      }
19  
20      public override ICommandResult Invoke()
21      {
22          WeakReferenceMessenger.Default.Send<QuitMessage>();
23          return CommandResult.KeepOpen();
24      }
25  
26      // this sneaky hidden behavior, I'm not event gonna try to localize this.
27      public void UpdateQuery(string query) => Name = query.StartsWith('q') ? "Quit" : string.Empty;
28  }