master
cpp 70 lines 1.74 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 ContainerListCommand.cpp
8
9 Abstract:
10
11 Implementation of command execution logic.
12
13 --*/
14
15 #include "ContainerCommand.h"
16 #include "CLIExecutionContext.h"
17 #include "ContainerTasks.h"
18 #include "SessionTasks.h"
19 #include "Task.h"
20
21 using namespace wsl::windows::wslc::execution;
22 using namespace wsl::windows::wslc::task;
23 using namespace wsl::shared;
24 using namespace wsl::shared::string;
25
26 namespace wsl::windows::wslc {
27 // Container List Command
28 std::vector<Argument> ContainerListCommand::GetArguments() const
29 {
30 return {
31 Argument::Create(ArgType::All),
32 Argument::Create(ArgType::Filter, {.Limit = Limit::Unlimited}),
33 Argument::Create(ArgType::Format),
34 Argument::Create(ArgType::Last),
35 Argument::Create(ArgType::Latest),
36 Argument::Create(ArgType::NoTrunc),
37 Argument::Create(ArgType::Quiet),
38 };
39 }
40
41 std::wstring ContainerListCommand::ShortDescription() const
42 {
43 return Localization::WSLCCLI_ContainerListDesc();
44 }
45
46 std::wstring ContainerListCommand::LongDescription() const
47 {
48 return Localization::WSLCCLI_ContainerListLongDesc();
49 }
50
51 // clang-format off
52 void ContainerListCommand::ExecuteInternal(CLIExecutionContext& context) const
53 {
54 context
55 << ResolveSession
56 << GetContainers
57 << ListContainers;
58 }
59 // clang-format on
60
61 void ContainerListCommand::ValidateArgumentsInternal(ArgMap& execArgs) const
62 {
63 if (execArgs.Contains(ArgType::Last) && execArgs.GetValue<ArgType::Latest>())
64 {
65 throw ArgumentException(
66 Localization::WSLCCLI_MultipleExclusiveArgumentsProvided(L"--last, --latest"),
67 GetArgumentsForHelp({ArgType::Last, ArgType::Latest}));
68 }
69 }
70 } // namespace wsl::windows::wslc