Skip to content

Commit d9bb591

Browse files
committed
Update source output
1 parent d708ba4 commit d9bb591

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

src/AppInstallerCLICore/Resources.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,10 @@ namespace AppInstaller::CLI::Resource
690690
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditCommandLongDescription);
691691
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditCommandShortDescription);
692692
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditExplicitArgumentDescription);
693-
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditOne);
693+
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditNewValue);
694694
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditNoChanges);
695+
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditOldValue);
696+
WINGET_DEFINE_RESOURCE_STRINGID(SourceEditOne);
695697
WINGET_DEFINE_RESOURCE_STRINGID(SourceExplicitArgumentDescription);
696698
WINGET_DEFINE_RESOURCE_STRINGID(SourceExportCommandLongDescription);
697699
WINGET_DEFINE_RESOURCE_STRINGID(SourceExportCommandShortDescription);

src/AppInstallerCLICore/Workflows/SourceFlow.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,13 @@ namespace AppInstaller::CLI::Workflow
281281
{
282282
// Get the current source with this name.
283283
Repository::Source targetSource{ sd.Name };
284+
auto oldExplicitValue = sd.Explicit;
284285

285286
// Default to the current explicit value unless we are overriding it.
286-
auto isExplicit = sd.Explicit;
287+
auto isExplicit = oldExplicitValue;
287288
if (context.Args.Contains(Execution::Args::Type::SourceEditExplicit))
288289
{
289-
auto explicitArg = context.Args.GetArg(Execution::Args::Type::SourceEditExplicit);
290-
isExplicit = Utility::ConvertStringToBool(explicitArg);
290+
isExplicit = Utility::ConvertStringToBool(context.Args.GetArg(Execution::Args::Type::SourceEditExplicit));
291291
}
292292

293293
Repository::SourceEdit edits{ std::optional<bool>{ isExplicit } };
@@ -297,9 +297,13 @@ namespace AppInstaller::CLI::Workflow
297297
continue;
298298
}
299299

300-
context.Reporter.Info() << Resource::String::SourceEditOne(Utility::LocIndView{ sd.Name }, Utility::LocIndView{ Utility::ConvertBoolToString(isExplicit) }) << std::endl;
300+
context.Reporter.Info() << Resource::String::SourceEditOne(Utility::LocIndView{ sd.Name }) << std::endl;
301301
targetSource.Edit(edits);
302-
context.Reporter.Info() << Resource::String::Done << std::endl;
302+
303+
// Output updated source information. Since only Explicit is editable, we will only list that field. The name of the source being edited is listed prior to the edits.
304+
Execution::TableOutput<3> table(context.Reporter, { Resource::String::SourceListField, Resource::String::SourceEditOldValue, Resource::String::SourceEditNewValue });
305+
table.OutputLine({ Resource::LocString(Resource::String::SourceListExplicit), std::string{ Utility::ConvertBoolToString(oldExplicitValue) }, std::string{ Utility::ConvertBoolToString(isExplicit) } });
306+
table.Complete();
303307
}
304308
}
305309

src/AppInstallerCLIE2ETests/SourceCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void SourceEdit()
289289
// Run the edit, this should be S_OK with "Done" as it changed the state to not-explicit.
290290
var editResult = TestCommon.RunAICLICommand("source edit", $"SourceTest --explicit false");
291291
Assert.AreEqual(Constants.ErrorCode.S_OK, editResult.ExitCode);
292-
Assert.True(editResult.StdOut.Contains("Done"));
292+
Assert.True(editResult.StdOut.Contains("Explicit"));
293293

294294
// Run it again, this should result in S_OK with no changes and a message that the source is already in that state.
295295
var editResult2 = TestCommon.RunAICLICommand("source edit", $"SourceTest --explicit false");
@@ -321,7 +321,7 @@ public void SourceEditOverrideDefault()
321321

322322
var editResult = TestCommon.RunAICLICommand("source edit", "winget-font -e false");
323323
Assert.AreEqual(Constants.ErrorCode.S_OK, editResult.ExitCode);
324-
Assert.True(editResult.StdOut.Contains("Done"));
324+
Assert.True(editResult.StdOut.Contains("Explicit"));
325325

326326
// Verify that after edit it is now explicit false.
327327
var listResult2 = TestCommon.RunAICLICommand("source list", "winget-font");

src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ They can be configured through the settings file 'winget settings'.</value>
552552
<value>Edit properties of a source</value>
553553
</data>
554554
<data name="SourceEditOne" xml:space="preserve">
555-
<value>Changing source: {0} to Explicit={1}...</value>
556-
<comment>{Locked="{0}","{1}"} Message displayed to inform the user about a registered repository source that is currently being edited. {0} is a placeholder replaced by the repository source name. {1} is a placeholder replaced by the changed value.</comment>
555+
<value>Editing source: {0}</value>
556+
<comment>{Locked="{0}"} Message displayed to inform the user about a registered repository source that is currently being edited. {0} is a placeholder replaced by the repository source name.</comment>
557557
</data>
558-
<data name="SourceEditNoChanges" xml:space="preserve">
558+
<data name="SourceEditNoChanges" xml:space="preserve">
559559
<value>The source named '{0}' is already in the desired state.</value>
560560
<comment>{Locked="{0}"} Message displayed to inform the user about a registered repository source that is currently being edited. {0} is a placeholder replaced by the repository source name.</comment>
561561
</data>
@@ -3475,4 +3475,12 @@ An unlocalized JSON fragment will follow on another line.</comment>
34753475
<data name="APPINSTALLER_CLI_ERROR_FONT_ALREADY_INSTALLED" xml:space="preserve">
34763476
<value>Font package is already installed.</value>
34773477
</data>
3478-
</root>
3478+
<data name="SourceEditOldValue" xml:space="preserve">
3479+
<value>Old value</value>
3480+
<comment>Column title for listing edit changes.</comment>
3481+
</data>
3482+
<data name="SourceEditNewValue" xml:space="preserve">
3483+
<value>New value</value>
3484+
<comment>Column title for listing the new value.</comment>
3485+
</data>
3486+
</root>

0 commit comments

Comments
 (0)