/ src / modules / cmdpal / ext / Microsoft.CmdPal.Ext.PowerToys / Modules / HostsModuleCommandProvider.cs
HostsModuleCommandProvider.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 System.Collections.Generic;
 6  using Microsoft.CommandPalette.Extensions.Toolkit;
 7  using PowerToysExtension.Commands;
 8  using PowerToysExtension.Helpers;
 9  using PowerToysExtension.Properties;
10  using static Common.UI.SettingsDeepLink;
11  
12  namespace PowerToysExtension.Modules;
13  
14  internal sealed class HostsModuleCommandProvider : ModuleCommandProvider
15  {
16      public override IEnumerable<ListItem> BuildCommands()
17      {
18          var module = SettingsWindow.Hosts;
19          var title = module.ModuleDisplayName();
20          var icon = module.ModuleIcon();
21  
22          if (ModuleEnablementService.IsModuleEnabled(module))
23          {
24              yield return new ListItem(new OpenHostsEditorCommand())
25              {
26                  Title = Resources.Hosts_Open_Title,
27                  Subtitle = Resources.Hosts_Open_Subtitle,
28                  Icon = icon,
29              };
30  
31              yield return new ListItem(new OpenHostsEditorAdminCommand())
32              {
33                  Title = Resources.Hosts_OpenAdmin_Title,
34                  Subtitle = Resources.Hosts_OpenAdmin_Subtitle,
35                  Icon = icon,
36              };
37          }
38  
39          yield return new ListItem(new OpenInSettingsCommand(module, title))
40          {
41              Title = title,
42              Subtitle = Resources.Hosts_Settings_Subtitle,
43              Icon = icon,
44          };
45      }
46  }