| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | ImageCommand.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | Declaration of command classes and interfaces. |
| 12 | |
| 13 | --*/ |
| 14 | #pragma once |
| 15 | #include "Command.h" |
| 16 | |
| 17 | namespace wsl::windows::wslc { |
| 18 | // Root Image Command |
| 19 | struct ImageCommand final : public Command |
| 20 | { |
| 21 | constexpr static std::wstring_view CommandName = L"image"; |
| 22 | ImageCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 23 | { |
| 24 | } |
| 25 | std::vector<Argument> GetArguments() const override; |
| 26 | std::wstring ShortDescription() const override; |
| 27 | std::wstring LongDescription() const override; |
| 28 | |
| 29 | std::vector<std::unique_ptr<Command>> GetCommands() const override; |
| 30 | |
| 31 | protected: |
| 32 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 33 | }; |
| 34 | |
| 35 | // Build Command |
| 36 | struct ImageBuildCommand final : public Command |
| 37 | { |
| 38 | constexpr static std::wstring_view CommandName = L"build"; |
| 39 | ImageBuildCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 40 | { |
| 41 | } |
| 42 | std::vector<Argument> GetArguments() const override; |
| 43 | std::wstring ShortDescription() const override; |
| 44 | std::wstring LongDescription() const override; |
| 45 | |
| 46 | protected: |
| 47 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 48 | }; |
| 49 | |
| 50 | // List Command |
| 51 | struct ImageListCommand final : public Command |
| 52 | { |
| 53 | constexpr static std::wstring_view CommandName = L"list"; |
| 54 | |
| 55 | // When parented directly to the root, ImageListCommand uses a different name |
| 56 | // to avoid colliding with the container list command. |
| 57 | constexpr static std::wstring_view RootCommandName = L"images"; |
| 58 | |
| 59 | ImageListCommand(const std::wstring& parent) : Command(CommandName, {L"ls"}, parent) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | // Image list has an alias 'images' off the root, which will collide with the |
| 64 | // container list command and its alias off the root. To avoid this, we will use |
| 65 | // an override constructor that changes the name and alias of the command for when |
| 66 | // it is parented directly to the root. |
| 67 | // The bool parameter is used as a tag to select the root-specific name. |
| 68 | ImageListCommand(const std::wstring& parent, bool /*rootScoped*/) : Command(RootCommandName, {}, parent) |
| 69 | { |
| 70 | } |
| 71 | std::vector<Argument> GetArguments() const override; |
| 72 | std::wstring ShortDescription() const override; |
| 73 | std::wstring LongDescription() const override; |
| 74 | |
| 75 | protected: |
| 76 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 77 | }; |
| 78 | |
| 79 | // Load Command |
| 80 | struct ImageLoadCommand final : public Command |
| 81 | { |
| 82 | constexpr static std::wstring_view CommandName = L"load"; |
| 83 | ImageLoadCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 84 | { |
| 85 | } |
| 86 | std::vector<Argument> GetArguments() const override; |
| 87 | std::wstring ShortDescription() const override; |
| 88 | std::wstring LongDescription() const override; |
| 89 | |
| 90 | protected: |
| 91 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 92 | }; |
| 93 | |
| 94 | // Import Command |
| 95 | struct ImageImportCommand final : public Command |
| 96 | { |
| 97 | constexpr static std::wstring_view CommandName = L"import"; |
| 98 | |
| 99 | ImageImportCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 100 | { |
| 101 | } |
| 102 | std::vector<Argument> GetArguments() const override; |
| 103 | std::wstring ShortDescription() const override; |
| 104 | std::wstring LongDescription() const override; |
| 105 | |
| 106 | protected: |
| 107 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 108 | }; |
| 109 | |
| 110 | // Remove Command |
| 111 | struct ImageRemoveCommand final : public Command |
| 112 | { |
| 113 | constexpr static std::wstring_view CommandName = L"remove"; |
| 114 | |
| 115 | // When parented directly to the root, ImageRemoveCommand uses a different name |
| 116 | constexpr static std::wstring_view RootCommandName = L"rmi"; |
| 117 | |
| 118 | ImageRemoveCommand(const std::wstring& parent) : Command(CommandName, {L"delete", L"rm"}, parent) |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | // Image remove has an alias 'rmi' off the root |
| 123 | // The bool parameter is used as a tag to select the root-specific name. |
| 124 | ImageRemoveCommand(const std::wstring& parent, bool /*rootScoped*/) : Command(RootCommandName, {}, parent) |
| 125 | { |
| 126 | } |
| 127 | std::vector<Argument> GetArguments() const override; |
| 128 | std::wstring ShortDescription() const override; |
| 129 | std::wstring LongDescription() const override; |
| 130 | |
| 131 | protected: |
| 132 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 133 | }; |
| 134 | |
| 135 | // Inspect Command |
| 136 | struct ImageInspectCommand final : public Command |
| 137 | { |
| 138 | constexpr static std::wstring_view CommandName = L"inspect"; |
| 139 | ImageInspectCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 140 | { |
| 141 | } |
| 142 | std::vector<Argument> GetArguments() const override; |
| 143 | std::wstring ShortDescription() const override; |
| 144 | std::wstring LongDescription() const override; |
| 145 | |
| 146 | protected: |
| 147 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 148 | }; |
| 149 | |
| 150 | // Pull Command |
| 151 | struct ImagePullCommand final : public Command |
| 152 | { |
| 153 | constexpr static std::wstring_view CommandName = L"pull"; |
| 154 | ImagePullCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 155 | { |
| 156 | } |
| 157 | std::vector<Argument> GetArguments() const override; |
| 158 | std::wstring ShortDescription() const override; |
| 159 | std::wstring LongDescription() const override; |
| 160 | |
| 161 | protected: |
| 162 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 163 | }; |
| 164 | |
| 165 | // Push Command |
| 166 | struct ImagePushCommand final : public Command |
| 167 | { |
| 168 | constexpr static std::wstring_view CommandName = L"push"; |
| 169 | ImagePushCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 170 | { |
| 171 | } |
| 172 | std::vector<Argument> GetArguments() const override; |
| 173 | std::wstring ShortDescription() const override; |
| 174 | std::wstring LongDescription() const override; |
| 175 | |
| 176 | protected: |
| 177 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 178 | }; |
| 179 | |
| 180 | // Save Command |
| 181 | struct ImageSaveCommand final : public Command |
| 182 | { |
| 183 | constexpr static std::wstring_view CommandName = L"save"; |
| 184 | ImageSaveCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 185 | { |
| 186 | } |
| 187 | std::vector<Argument> GetArguments() const override; |
| 188 | std::wstring ShortDescription() const override; |
| 189 | std::wstring LongDescription() const override; |
| 190 | |
| 191 | protected: |
| 192 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 193 | }; |
| 194 | |
| 195 | // Tag Command |
| 196 | struct ImageTagCommand final : public Command |
| 197 | { |
| 198 | constexpr static std::wstring_view CommandName = L"tag"; |
| 199 | ImageTagCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 200 | { |
| 201 | } |
| 202 | std::vector<Argument> GetArguments() const override; |
| 203 | std::wstring ShortDescription() const override; |
| 204 | std::wstring LongDescription() const override; |
| 205 | |
| 206 | protected: |
| 207 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 208 | }; |
| 209 | |
| 210 | // Prune Command |
| 211 | struct ImagePruneCommand final : public Command |
| 212 | { |
| 213 | constexpr static std::wstring_view CommandName = L"prune"; |
| 214 | ImagePruneCommand(const std::wstring& parent) : Command(CommandName, parent) |
| 215 | { |
| 216 | } |
| 217 | std::vector<Argument> GetArguments() const override; |
| 218 | std::wstring ShortDescription() const override; |
| 219 | std::wstring LongDescription() const override; |
| 220 | |
| 221 | protected: |
| 222 | void ExecuteInternal(CLIExecutionContext& context) const override; |
| 223 | }; |
| 224 | } // namespace wsl::windows::wslc |