Skip to content

Commit fa450eb

Browse files
committed
Copilot feedback #2 and format
1 parent 8744be2 commit fa450eb

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/windows/wslc/commands/ImageCommand.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ struct ImageCommand final : public Command
3636
struct ImageListCommand final : public Command
3737
{
3838
constexpr static std::wstring_view CommandName = L"list";
39+
40+
// When parented directly to the root, ImageListCommand uses a different name
41+
// to avoid colliding with the container list command.
42+
constexpr static std::wstring_view RootCommandName = L"images";
43+
3944
ImageListCommand(const std::wstring& parent) : Command(CommandName, {L"ls"}, parent)
4045
{
4146
}
@@ -44,7 +49,8 @@ struct ImageListCommand final : public Command
4449
// container list command and its alias off the root. To avoid this, we will use
4550
// an override constructor that changes the name and alias of the command for when
4651
// it is parented directly to the root.
47-
ImageListCommand(const std::wstring& parent, const std::wstring_view name) : Command(name, {}, parent)
52+
// The bool parameter is used as a tag to select the root-specific name.
53+
ImageListCommand(const std::wstring& parent, bool /*rootScoped*/) : Command(RootCommandName, {}, parent)
4854
{
4955
}
5056
std::vector<Argument> GetArguments() const override;

‎src/windows/wslc/commands/RootCommand.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ std::vector<std::unique_ptr<Command>> RootCommand::GetCommands() const
3030
commands.push_back(std::make_unique<ContainerCreateCommand>(FullName()));
3131
commands.push_back(std::make_unique<ContainerDeleteCommand>(FullName()));
3232
commands.push_back(std::make_unique<ContainerExecCommand>(FullName()));
33-
commands.push_back(std::make_unique<ImageListCommand>(FullName(), L"images")); // Aliased to avoid collision.
33+
commands.push_back(std::make_unique<ImageListCommand>(FullName(), true));
3434
commands.push_back(std::make_unique<ContainerInspectCommand>(FullName()));
3535
commands.push_back(std::make_unique<ContainerKillCommand>(FullName()));
3636
commands.push_back(std::make_unique<ContainerListCommand>(FullName()));

‎src/windows/wslc/tasks/ImageTasks.cpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void ListImages(CLIExecutionContext& context)
4444

4545
if (context.Args.Contains(ArgType::Quiet))
4646
{
47-
// Print only the image ids
47+
// Print only the image names.
4848
for (const auto& image : images)
4949
{
5050
PrintMessage(MultiByteToWide(image.Name));
@@ -72,8 +72,7 @@ void ListImages(CLIExecutionContext& context)
7272
utils::TablePrinter tablePrinter({L"NAME", L"SIZE (MB)"});
7373
for (const auto& image : images)
7474
{
75-
tablePrinter.AddRow(
76-
{MultiByteToWide(image.Name), std::format(L"{:.2f}", static_cast<double>(image.Size) / (1024 * 1024))});
75+
tablePrinter.AddRow({MultiByteToWide(image.Name), std::format(L"{:.2f}", static_cast<double>(image.Size) / (1024 * 1024))});
7776
}
7877

7978
tablePrinter.Print();

0 commit comments

Comments
 (0)