Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for smaller configuration outputs #4754

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ namespace AppInstaller::CLI
return { type, "file"_liv, 'f', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice };
case Execution::Args::Type::ConfigurationAcceptWarning:
return { type, "accept-configuration-agreements"_liv };
case Execution::Args::Type::ConfigurationSuppressPrologue:
return { type, "suppress-initial-details"_liv };
case Execution::Args::Type::ConfigurationEnable:
return { type, "enable"_liv, ArgTypeCategory::None, ArgTypeExclusiveSet::StubType };
case Execution::Args::Type::ConfigurationDisable:
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Commands/ConfigureCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace AppInstaller::CLI
Argument{ Execution::Args::Type::ConfigurationModulePath, Resource::String::ConfigurationModulePath, ArgumentType::Positional },
Argument{ Execution::Args::Type::ConfigurationHistoryItem, Resource::String::ConfigurationHistoryItemArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationAcceptWarning, Resource::String::ConfigurationAcceptWarningArgumentDescription, ArgumentType::Flag },
Argument{ Execution::Args::Type::ConfigurationSuppressPrologue, Resource::String::ConfigurationSuppressPrologueArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationEnable, Resource::String::ConfigurationEnableMessage, ArgumentType::Flag, Argument::Visibility::Help },
Argument{ Execution::Args::Type::ConfigurationDisable, Resource::String::ConfigurationDisableMessage, ArgumentType::Flag, Argument::Visibility::Help },
};
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/ExecutionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace AppInstaller::CLI::Execution
// Configuration
ConfigurationFile,
ConfigurationAcceptWarning,
ConfigurationSuppressPrologue,
ConfigurationEnable,
ConfigurationDisable,
ConfigurationModulePath,
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationSettings);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationStatusWatchArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationSuccessfullyApplied);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationSuppressPrologueArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationUnexpectedTestResult);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationUnitAssertHadNegativeResult);
WINGET_DEFINE_RESOURCE_STRINGID(ConfigurationUnitFailed);
Expand Down
47 changes: 27 additions & 20 deletions src/AppInstallerCLICore/Workflows/ConfigurationFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,27 +1369,31 @@ namespace AppInstaller::CLI::Workflow
auto getDetailsOperation = configContext.Processor().GetSetDetailsAsync(configContext.Set(), ConfigurationUnitDetailFlags::ReadOnly);
auto unification = anon::CreateProgressCancellationUnification(std::move(progressScope), getDetailsOperation);

bool suppressDetailsOutput = context.Args.Contains(Args::Type::ConfigurationAcceptWarning) && context.Args.Contains(Args::Type::ConfigurationSuppressPrologue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that supress-prologue is not used on its own?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only controls output, not the results. I don't see it as harmful to be passed when it wouldn't do anything.

anon::OutputHelper outputHelper{ context };
uint32_t unitsShown = 0;

getDetailsOperation.Progress([&](const IAsyncOperationWithProgress<GetConfigurationSetDetailsResult, GetConfigurationUnitDetailsResult>& operation, const GetConfigurationUnitDetailsResult&)
{
auto threadContext = context.SetForCurrentThread();
if (!suppressDetailsOutput)
{
getDetailsOperation.Progress([&](const IAsyncOperationWithProgress<GetConfigurationSetDetailsResult, GetConfigurationUnitDetailsResult>& operation, const GetConfigurationUnitDetailsResult&)
{
auto threadContext = context.SetForCurrentThread();

unification.Reset();
unification.Reset();

auto unitResults = operation.GetResults().UnitResults();
for (unitsShown; unitsShown < unitResults.Size(); ++unitsShown)
{
GetConfigurationUnitDetailsResult unitResult = unitResults.GetAt(unitsShown);
anon::LogFailedGetConfigurationUnitDetails(unitResult.Unit(), unitResult.ResultInformation());
outputHelper.OutputConfigurationUnitInformation(unitResult.Unit());
}
auto unitResults = operation.GetResults().UnitResults();
for (unitsShown; unitsShown < unitResults.Size(); ++unitsShown)
{
GetConfigurationUnitDetailsResult unitResult = unitResults.GetAt(unitsShown);
anon::LogFailedGetConfigurationUnitDetails(unitResult.Unit(), unitResult.ResultInformation());
outputHelper.OutputConfigurationUnitInformation(unitResult.Unit());
}

progressScope = context.Reporter.BeginAsyncProgress(true);
progressScope->Callback().SetProgressMessage(gettingDetailString);
unification.Progress(std::move(progressScope));
});
progressScope = context.Reporter.BeginAsyncProgress(true);
progressScope->Callback().SetProgressMessage(gettingDetailString);
unification.Progress(std::move(progressScope));
});
}

HRESULT hr = S_OK;
GetConfigurationSetDetailsResult result = nullptr;
Expand Down Expand Up @@ -1419,7 +1423,7 @@ namespace AppInstaller::CLI::Workflow
}

// Handle any missing progress callbacks that are in the results
if (result)
if (result && !suppressDetailsOutput)
{
auto unitResults = result.UnitResults();
if (unitResults)
Expand All @@ -1434,11 +1438,14 @@ namespace AppInstaller::CLI::Workflow
}

// Handle any units that are NOT in the results (due to an exception part of the way through)
auto allUnits = configContext.Set().Units();
for (unitsShown; unitsShown < allUnits.Size(); ++unitsShown)
if (!suppressDetailsOutput)
{
ConfigurationUnit unit = allUnits.GetAt(unitsShown);
outputHelper.OutputConfigurationUnitInformation(unit);
auto allUnits = configContext.Set().Units();
for (unitsShown; unitsShown < allUnits.Size(); ++unitsShown)
{
ConfigurationUnit unit = allUnits.GetAt(unitsShown);
outputHelper.OutputConfigurationUnitInformation(unit);
}
}

if (outputHelper.ValuesTruncated)
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3109,4 +3109,7 @@ Please specify one of them using the --source option to proceed.</value>
<data name="StoreInstall_PackageNotAvailableForCurrentSystem" xml:space="preserve">
<value>The package is not compatible with the current Windows version or platform.</value>
</data>
<data name="ConfigurationSuppressPrologueArgumentDescription" xml:space="preserve">
<value>Suppress showing initial configuration details when possible</value>
</data>
</root>
7 changes: 7 additions & 0 deletions src/ConfigurationRemotingServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ internal class Program

static int Main(string[] args)
{
// Remove any attached console to prevent modules (or their actions) from writing to our console.
FreeConsole();

// Help find WindowsPackageManager.dll
AssemblyLoadContext.Default.ResolvingUnmanagedDll += NativeAssemblyLoadContext.ResolvingUnmanagedHandler;

Expand Down Expand Up @@ -196,5 +199,9 @@ private static extern int WindowsPackageManagerConfigurationCompleteOutOfProcess

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr GetCommandLineW();

[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FreeConsole();
}
}
Loading