winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

FeaturesCommand.cpp (2442B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include "FeaturesCommand.h"
      5 #include "TableOutput.h"
      6 #include <winget/UserSettings.h>
      7 
      8 namespace AppInstaller::CLI
      9 {
     10     using namespace Utility::literals;
     11     using namespace AppInstaller::Settings;
     12 
     13     Resource::LocString FeaturesCommand::ShortDescription() const
     14     {
     15         return { Resource::String::FeaturesCommandShortDescription };
     16     }
     17 
     18     Resource::LocString FeaturesCommand::LongDescription() const
     19     {
     20         return { Resource::String::FeaturesCommandLongDescription };
     21     }
     22 
     23     Utility::LocIndView FeaturesCommand::HelpLink() const
     24     {
     25         return "https://aka.ms/winget-experimentalfeatures"_liv;
     26     }
     27 
     28     void FeaturesCommand::ExecuteInternal(Execution::Context& context) const
     29     {
     30 #ifdef WINGET_DISABLE_EXPERIMENTAL_FEATURES
     31         context.Reporter.Info() << Resource::String::FeaturesMessageDisabledByBuild << std::endl;
     32 #else
     33         if (GroupPolicies().IsEnabled(TogglePolicy::Policy::ExperimentalFeatures) &&
     34             GroupPolicies().IsEnabled(TogglePolicy::Policy::Settings))
     35         {
     36             context.Reporter.Info() << Resource::String::FeaturesMessage << std::endl << std::endl;
     37         }
     38         else
     39         {
     40             context.Reporter.Info() << Resource::String::FeaturesMessageDisabledByPolicy << std::endl << std::endl;
     41         }
     42 
     43         auto features = ExperimentalFeature::GetAllFeatures();
     44 
     45         if (!features.empty())
     46         {
     47             Execution::TableOutput<4> table(context.Reporter, {
     48                 Resource::String::FeaturesFeature,
     49                 Resource::String::FeaturesStatus,
     50                 Resource::String::FeaturesProperty,
     51                 Resource::String::FeaturesLink });
     52             for (const auto& feature : features)
     53             {
     54                 table.OutputLine({
     55                     std::string{ feature.Name() },
     56                     Resource::LocString{ ExperimentalFeature::IsEnabled(feature.GetFeature()) ? Resource::String::FeaturesEnabled : Resource::String::FeaturesDisabled},
     57                     std::string { feature.JsonName() },
     58                     std::string{ feature.Link() } });
     59             }
     60             table.Complete();
     61         }
     62         else
     63         {
     64             // Better work hard to get some out there!
     65             context.Reporter.Info() << Resource::String::NoExperimentalFeaturesMessage << std::endl;
     66         }
     67 #endif
     68     }
     69 }