├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── DockerCompletion ├── Compose │ ├── completers.ps1 │ └── completers4arguments.ps1 ├── DockerCompletion.psd1 ├── DockerCompletion.psm1 ├── DockerCompletionUtility │ ├── DockerCompletionUtility.psd1 │ └── DockerCompletionUtility.psm1 ├── NativeCommandCompletion │ ├── NativeCommandCompletion.psd1 │ └── NativeCommandCompletion.psm1 ├── OSSLICENSES.txt ├── completers.ps1 └── completers4arguments.ps1 ├── LICENSE ├── README.md ├── Tests ├── DockerCompletion.DOCKER_HIDE_LEGACY_COMMANDS.Tests.ps1 ├── DockerCompletion.Tests.ps1 └── test.yaml └── demo.gif /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.powershell" 4 | ] 5 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "PowerShell", 6 | "request": "launch", 7 | "name": "Interactive Session", 8 | "program": "pwsh", 9 | "args": [ 10 | "-NoExit", 11 | "-NoProfile" 12 | ], 13 | "cwd": "${workspaceFolder}" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.detectIndentation": false, 3 | "editor.insertSpaces": false, 4 | "powershell.codeFormatting.newLineAfterCloseBrace": false, 5 | } -------------------------------------------------------------------------------- /DockerCompletion/Compose/completers.ps1: -------------------------------------------------------------------------------- 1 | # Docker Compose version v2.35.1 2 | Register-Completer docker_compose { 3 | COMPGEN alpha SubCommand 'Experimental commands' 4 | COMPGEN attach SubCommand 'Attach local standard input, output, and error streams to a service''s running container' 5 | COMPGEN build SubCommand 'Build or rebuild services' 6 | COMPGEN commit SubCommand 'Create a new image from a service container''s changes' 7 | COMPGEN config SubCommand 'Parse, resolve and render compose file in canonical format' 8 | COMPGEN cp SubCommand 'Copy files/folders between a service container and the local filesystem' 9 | COMPGEN create SubCommand 'Creates containers for a service' 10 | COMPGEN down SubCommand 'Stop and remove containers, networks' 11 | COMPGEN events SubCommand 'Receive real time events from containers' 12 | COMPGEN exec SubCommand 'Execute a command in a running container' 13 | COMPGEN export SubCommand 'Export a service container''s filesystem as a tar archive' 14 | COMPGEN images SubCommand 'List images used by the created containers' 15 | COMPGEN kill SubCommand 'Force stop service containers' 16 | COMPGEN logs SubCommand 'View output from containers' 17 | COMPGEN ls SubCommand 'List running compose projects' 18 | COMPGEN pause SubCommand 'Pause services' 19 | COMPGEN port SubCommand 'Print the public port for a port binding' 20 | COMPGEN ps SubCommand 'List containers' 21 | COMPGEN publish SubCommand 'Publish compose application' 22 | COMPGEN pull SubCommand 'Pull service images' 23 | COMPGEN push SubCommand 'Push service images' 24 | COMPGEN restart SubCommand 'Restart service containers' 25 | COMPGEN rm SubCommand 'Removes stopped service containers' 26 | COMPGEN run SubCommand 'Run a one-off command on a service' 27 | COMPGEN scale SubCommand 'Scale services ' 28 | COMPGEN start SubCommand 'Start services' 29 | COMPGEN stats SubCommand 'Display a live stream of container(s) resource usage statistics' 30 | COMPGEN stop SubCommand 'Stop services' 31 | COMPGEN top SubCommand 'Display the running processes' 32 | COMPGEN unpause SubCommand 'Unpause services' 33 | COMPGEN up SubCommand 'Create and start containers' 34 | COMPGEN version SubCommand 'Show the Docker Compose version information' 35 | COMPGEN wait SubCommand 'Block until containers of all (or specified) services stop.' 36 | COMPGEN watch SubCommand 'Watch build context for service and rebuild/refresh containers when files are updated' 37 | } 38 | 39 | Register-Completer docker_compose -Option { 40 | COMPGEN --all-resources Switch 'Include all resources, even those not used by services' 41 | COMPGEN --ansi string 'Control when to print ANSI control characters ("never"|"always"|"auto")' 42 | COMPGEN --compatibility Switch 'Run compose in backward compatibility mode' 43 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 44 | COMPGEN --env-file stringArray 'Specify an alternate environment file' 45 | COMPGEN '-f' stringArray 'Compose configuration files' 46 | COMPGEN --file stringArray 'Compose configuration files' 47 | COMPGEN --no-ansi Switch 'Do not print ANSI control characters (DEPRECATED)' 48 | COMPGEN --parallel int 'Control max parallelism, -1 for unlimited' 49 | COMPGEN --profile stringArray 'Specify a profile to enable' 50 | COMPGEN --progress string 'Set type of progress output (auto, tty, plain, json, quiet)' 51 | COMPGEN --project-directory string 'Specify an alternate working directory 52 | (default: the path of the, first specified, Compose file)' 53 | COMPGEN '-p' string 'Project name' 54 | COMPGEN --project-name string 'Project name' 55 | COMPGEN --verbose Switch 'Show more output' 56 | COMPGEN '-v' Switch 'Show the Docker Compose version information' 57 | COMPGEN --version Switch 'Show the Docker Compose version information' 58 | COMPGEN --workdir string 'DEPRECATED! USE --project-directory INSTEAD. 59 | Specify an alternate working directory 60 | (default: the path of the, first specified, Compose file)' 61 | } 62 | 63 | Register-Completer docker_compose_attach -Option { 64 | COMPGEN --detach-keys string 'Override the key sequence for detaching from a container.' 65 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 66 | COMPGEN --index int 'index of the container if service has multiple replicas.' 67 | COMPGEN --no-stdin Switch 'Do not attach STDIN' 68 | COMPGEN --sig-proxy Switch 'Proxy all received signals to the process' 69 | } 70 | 71 | Register-Completer docker_compose_build -Option { 72 | COMPGEN --build-arg stringArray 'Set build-time variables for services' 73 | COMPGEN --builder string 'Set builder to use' 74 | COMPGEN --compress Switch 'Compress the build context using gzip. DEPRECATED' 75 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 76 | COMPGEN --force-rm Switch 'Always remove intermediate containers. DEPRECATED' 77 | COMPGEN '-m' bytes 'Set memory limit for the build container. Not supported by BuildKit.' 78 | COMPGEN --memory bytes 'Set memory limit for the build container. Not supported by BuildKit.' 79 | COMPGEN --no-cache Switch 'Do not use cache when building the image' 80 | COMPGEN --no-rm Switch 'Do not remove intermediate containers after a successful build. DEPRECATED' 81 | COMPGEN --parallel Switch 'Build images in parallel. DEPRECATED' 82 | COMPGEN --print Switch 'Print equivalent bake file' 83 | COMPGEN --progress string 'Set type of ui output (auto, tty, plain, json, quiet)' 84 | COMPGEN --pull Switch 'Always attempt to pull a newer version of the image' 85 | COMPGEN --push Switch 'Push service images' 86 | COMPGEN '-q' Switch 'Don''t print anything to STDOUT' 87 | COMPGEN --quiet Switch 'Don''t print anything to STDOUT' 88 | COMPGEN --ssh string 'Set SSH authentications used when building service images. (use ''default'' for using your default SSH Agent)' 89 | COMPGEN --with-dependencies Switch 'Also build dependencies (transitively)' 90 | } 91 | 92 | Register-Completer docker_compose_commit -Option { 93 | COMPGEN '-a' string 'Author (e.g., "John Hannibal Smith ")' 94 | COMPGEN --author string 'Author (e.g., "John Hannibal Smith ")' 95 | COMPGEN '-c' list 'Apply Dockerfile instruction to the created image' 96 | COMPGEN --change list 'Apply Dockerfile instruction to the created image' 97 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 98 | COMPGEN --index int 'index of the container if service has multiple replicas.' 99 | COMPGEN '-m' string 'Commit message' 100 | COMPGEN --message string 'Commit message' 101 | COMPGEN '-p' Switch 'Pause container during commit' 102 | COMPGEN --pause Switch 'Pause container during commit' 103 | } 104 | 105 | Register-Completer docker_compose_config -Option { 106 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 107 | COMPGEN --environment Switch 'Print environment used for interpolation.' 108 | COMPGEN --format string 'Format the output. Values: [yaml | json]' 109 | COMPGEN --hash string 'Print the service config hash, one per line.' 110 | COMPGEN --images Switch 'Print the image names, one per line.' 111 | COMPGEN --no-consistency Switch 'Don''t check model consistency - warning: may produce invalid Compose output' 112 | COMPGEN --no-env-resolution Switch 'Don''t resolve service env files' 113 | COMPGEN --no-interpolate Switch 'Don''t interpolate environment variables' 114 | COMPGEN --no-normalize Switch 'Don''t normalize compose model' 115 | COMPGEN --no-path-resolution Switch 'Don''t resolve file paths' 116 | COMPGEN '-o' string 'Save to file (default to stdout)' 117 | COMPGEN --output string 'Save to file (default to stdout)' 118 | COMPGEN --profiles Switch 'Print the profile names, one per line.' 119 | COMPGEN '-q' Switch 'Only validate the configuration, don''t print anything' 120 | COMPGEN --quiet Switch 'Only validate the configuration, don''t print anything' 121 | COMPGEN --resolve-image-digests Switch 'Pin image tags to digests' 122 | COMPGEN --services Switch 'Print the service names, one per line.' 123 | COMPGEN --variables Switch 'Print model variables and default values.' 124 | COMPGEN --volumes Switch 'Print the volume names, one per line.' 125 | } 126 | 127 | Register-Completer docker_compose_cp -Option { 128 | COMPGEN --all Switch 'Include containers created by the run command' 129 | COMPGEN '-a' Switch 'Archive mode (copy all uid/gid information)' 130 | COMPGEN --archive Switch 'Archive mode (copy all uid/gid information)' 131 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 132 | COMPGEN '-L' Switch 'Always follow symbol link in SRC_PATH' 133 | COMPGEN --follow-link Switch 'Always follow symbol link in SRC_PATH' 134 | COMPGEN --index int 'Index of the container if service has multiple replicas' 135 | } 136 | 137 | Register-Completer docker_compose_create -Option { 138 | COMPGEN --build Switch 'Build images before starting containers' 139 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 140 | COMPGEN --force-recreate Switch 'Recreate containers even if their configuration and image haven''t changed' 141 | COMPGEN --no-build Switch 'Don''t build an image, even if it''s policy' 142 | COMPGEN --no-recreate Switch 'If containers already exist, don''t recreate them. Incompatible with --force-recreate.' 143 | COMPGEN --pull string 'Pull image before running ("always"|"missing"|"never"|"build")' 144 | COMPGEN --quiet-pull Switch 'Pull without printing progress information' 145 | COMPGEN --remove-orphans Switch 'Remove containers for services not defined in the Compose file' 146 | COMPGEN --scale stringArray 'Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.' 147 | COMPGEN '-y' Switch 'Assume "yes" as answer to all prompts and run non-interactively' 148 | COMPGEN --yes Switch 'Assume "yes" as answer to all prompts and run non-interactively' 149 | } 150 | 151 | Register-Completer docker_compose_down -Option { 152 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 153 | COMPGEN --remove-orphans Switch 'Remove containers for services not defined in the Compose file' 154 | COMPGEN --rmi string 'Remove images used by services. "local" remove only images that don''t have a custom tag ("local"|"all")' 155 | COMPGEN '-t' int 'Specify a shutdown timeout in seconds' 156 | COMPGEN --timeout int 'Specify a shutdown timeout in seconds' 157 | COMPGEN '-v' Switch 'Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers' 158 | COMPGEN --volumes Switch 'Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers' 159 | } 160 | 161 | Register-Completer docker_compose_events -Option { 162 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 163 | COMPGEN --json Switch 'Output events as a stream of json objects' 164 | } 165 | 166 | Register-Completer docker_compose_exec -Option { 167 | COMPGEN '-d' Switch 'Detached mode: Run command in the background' 168 | COMPGEN --detach Switch 'Detached mode: Run command in the background' 169 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 170 | COMPGEN '-e' stringArray 'Set environment variables' 171 | COMPGEN --env stringArray 'Set environment variables' 172 | COMPGEN --index int 'Index of the container if service has multiple replicas' 173 | COMPGEN '-i' Switch 'Keep STDIN open even if not attached' 174 | COMPGEN --interactive Switch 'Keep STDIN open even if not attached' 175 | COMPGEN '-T' Switch 'Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.' 176 | COMPGEN --no-TTY Switch 'Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.' 177 | COMPGEN --privileged Switch 'Give extended privileges to the process' 178 | COMPGEN '-t' Switch 'Allocate a pseudo-TTY' 179 | COMPGEN --tty Switch 'Allocate a pseudo-TTY' 180 | COMPGEN '-u' string 'Run the command as this user' 181 | COMPGEN --user string 'Run the command as this user' 182 | COMPGEN '-w' string 'Path to workdir directory for this command' 183 | COMPGEN --workdir string 'Path to workdir directory for this command' 184 | } 185 | 186 | Register-Completer docker_compose_export -Option { 187 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 188 | COMPGEN --index int 'index of the container if service has multiple replicas.' 189 | COMPGEN '-o' string 'Write to a file, instead of STDOUT' 190 | COMPGEN --output string 'Write to a file, instead of STDOUT' 191 | } 192 | 193 | Register-Completer docker_compose_images -Option { 194 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 195 | COMPGEN --format string 'Format the output. Values: [table | json]' 196 | COMPGEN '-q' Switch 'Only display IDs' 197 | COMPGEN --quiet Switch 'Only display IDs' 198 | } 199 | 200 | Register-Completer docker_compose_kill -Option { 201 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 202 | COMPGEN --remove-orphans Switch 'Remove containers for services not defined in the Compose file' 203 | COMPGEN '-s' string 'SIGNAL to send to the container' 204 | COMPGEN --signal string 'SIGNAL to send to the container' 205 | } 206 | 207 | Register-Completer docker_compose_logs -Option { 208 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 209 | COMPGEN '-f' Switch 'Follow log output' 210 | COMPGEN --follow Switch 'Follow log output' 211 | COMPGEN --index int 'index of the container if service has multiple replicas' 212 | COMPGEN --no-color Switch 'Produce monochrome output' 213 | COMPGEN --no-log-prefix Switch 'Don''t print prefix in logs' 214 | COMPGEN --since string 'Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)' 215 | COMPGEN '-n' string 'Number of lines to show from the end of the logs for each container' 216 | COMPGEN --tail string 'Number of lines to show from the end of the logs for each container' 217 | COMPGEN '-t' Switch 'Show timestamps' 218 | COMPGEN --timestamps Switch 'Show timestamps' 219 | COMPGEN --until string 'Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)' 220 | } 221 | 222 | Register-Completer docker_compose_ls -Option { 223 | COMPGEN '-a' Switch 'Show all stopped Compose projects' 224 | COMPGEN --all Switch 'Show all stopped Compose projects' 225 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 226 | COMPGEN --filter filter 'Filter output based on conditions provided' 227 | COMPGEN --format string 'Format the output. Values: [table | json]' 228 | COMPGEN '-q' Switch 'Only display project names' 229 | COMPGEN --quiet Switch 'Only display project names' 230 | } 231 | 232 | Register-Completer docker_compose_port -Option { 233 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 234 | COMPGEN --index int 'Index of the container if service has multiple replicas' 235 | COMPGEN --protocol string 'tcp or udp' 236 | } 237 | 238 | Register-Completer docker_compose_ps -Option { 239 | COMPGEN '-a' Switch 'Show all stopped containers (including those created by the run command)' 240 | COMPGEN --all Switch 'Show all stopped containers (including those created by the run command)' 241 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 242 | COMPGEN --filter string 'Filter services by a property (supported filters: status)' 243 | COMPGEN --format string 'Format output using a custom template: 244 | ''table'': Print output in table format with column headers (default) 245 | ''table TEMPLATE'': Print output in table format using the given Go template 246 | ''json'': Print in JSON format 247 | ''TEMPLATE'': Print output using the given Go template. 248 | Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates' 249 | COMPGEN --no-trunc Switch 'Don''t truncate output' 250 | COMPGEN --orphans Switch 'Include orphaned services (not declared by project)' 251 | COMPGEN '-q' Switch 'Only display IDs' 252 | COMPGEN --quiet Switch 'Only display IDs' 253 | COMPGEN --services Switch 'Display services' 254 | COMPGEN --status stringArray 'Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]' 255 | } 256 | 257 | Register-Completer docker_compose_publish -Option { 258 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 259 | COMPGEN --oci-version string 'OCI image/artifact specification version (automatically determined by default)' 260 | COMPGEN --resolve-image-digests Switch 'Pin image tags to digests' 261 | COMPGEN --with-env Switch 'Include environment variables in the published OCI artifact' 262 | COMPGEN '-y' Switch 'Assume "yes" as answer to all prompts' 263 | COMPGEN --yes Switch 'Assume "yes" as answer to all prompts' 264 | } 265 | 266 | Register-Completer docker_compose_pull -Option { 267 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 268 | COMPGEN --ignore-buildable Switch 'Ignore images that can be built' 269 | COMPGEN --ignore-pull-failures Switch 'Pull what it can and ignores images with pull failures' 270 | COMPGEN --include-deps Switch 'Also pull services declared as dependencies' 271 | COMPGEN --no-parallel Switch 'DEPRECATED disable parallel pulling' 272 | COMPGEN --parallel Switch 'DEPRECATED pull multiple images in parallel' 273 | COMPGEN --policy string 'Apply pull policy ("missing"|"always")' 274 | COMPGEN '-q' Switch 'Pull without printing progress information' 275 | COMPGEN --quiet Switch 'Pull without printing progress information' 276 | } 277 | 278 | Register-Completer docker_compose_push -Option { 279 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 280 | COMPGEN --ignore-push-failures Switch 'Push what it can and ignores images with push failures' 281 | COMPGEN --include-deps Switch 'Also push images of services declared as dependencies' 282 | COMPGEN '-q' Switch 'Push without printing progress information' 283 | COMPGEN --quiet Switch 'Push without printing progress information' 284 | } 285 | 286 | Register-Completer docker_compose_restart -Option { 287 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 288 | COMPGEN --no-deps Switch 'Don''t restart dependent services' 289 | COMPGEN '-t' int 'Specify a shutdown timeout in seconds' 290 | COMPGEN --timeout int 'Specify a shutdown timeout in seconds' 291 | } 292 | 293 | Register-Completer docker_compose_rm -Option { 294 | COMPGEN '-a' Switch 'Deprecated - no effect' 295 | COMPGEN --all Switch 'Deprecated - no effect' 296 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 297 | COMPGEN '-f' Switch 'Don''t ask to confirm removal' 298 | COMPGEN --force Switch 'Don''t ask to confirm removal' 299 | COMPGEN '-s' Switch 'Stop the containers, if required, before removing' 300 | COMPGEN --stop Switch 'Stop the containers, if required, before removing' 301 | COMPGEN '-v' Switch 'Remove any anonymous volumes attached to containers' 302 | COMPGEN --volumes Switch 'Remove any anonymous volumes attached to containers' 303 | } 304 | 305 | Register-Completer docker_compose_run -Option { 306 | COMPGEN --build Switch 'Build image before starting container' 307 | COMPGEN --cap-add list 'Add Linux capabilities' 308 | COMPGEN --cap-drop list 'Drop Linux capabilities' 309 | COMPGEN '-d' Switch 'Run container in background and print container ID' 310 | COMPGEN --detach Switch 'Run container in background and print container ID' 311 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 312 | COMPGEN --entrypoint string 'Override the entrypoint of the image' 313 | COMPGEN '-e' stringArray 'Set environment variables' 314 | COMPGEN --env stringArray 'Set environment variables' 315 | COMPGEN --env-from-file stringArray 'Set environment variables from file' 316 | COMPGEN '-i' Switch 'Keep STDIN open even if not attached' 317 | COMPGEN --interactive Switch 'Keep STDIN open even if not attached' 318 | COMPGEN '-l' stringArray 'Add or override a label' 319 | COMPGEN --label stringArray 'Add or override a label' 320 | COMPGEN --name string 'Assign a name to the container' 321 | COMPGEN '-T' Switch 'Disable pseudo-TTY allocation (default: auto-detected)' 322 | COMPGEN --no-TTY Switch 'Disable pseudo-TTY allocation (default: auto-detected)' 323 | COMPGEN --no-deps Switch 'Don''t start linked services' 324 | COMPGEN '-p' stringArray 'Publish a container''s port(s) to the host' 325 | COMPGEN --publish stringArray 'Publish a container''s port(s) to the host' 326 | COMPGEN --pull string 'Pull image before running ("always"|"missing"|"never")' 327 | COMPGEN '-q' Switch 'Don''t print anything to STDOUT' 328 | COMPGEN --quiet Switch 'Don''t print anything to STDOUT' 329 | COMPGEN --quiet-build Switch 'Suppress progress output from the build process' 330 | COMPGEN --quiet-pull Switch 'Pull without printing progress information' 331 | COMPGEN --remove-orphans Switch 'Remove containers for services not defined in the Compose file' 332 | COMPGEN --rm Switch 'Automatically remove the container when it exits' 333 | COMPGEN '-P' Switch 'Run command with all service''s ports enabled and mapped to the host' 334 | COMPGEN --service-ports Switch 'Run command with all service''s ports enabled and mapped to the host' 335 | COMPGEN '-t' Switch 'Allocate a pseudo-TTY' 336 | COMPGEN --tty Switch 'Allocate a pseudo-TTY' 337 | COMPGEN --use-aliases Switch 'Use the service''s network useAliases in the network(s) the container connects to' 338 | COMPGEN '-u' string 'Run as specified username or uid' 339 | COMPGEN --user string 'Run as specified username or uid' 340 | COMPGEN '-v' stringArray 'Bind mount a volume' 341 | COMPGEN --volume stringArray 'Bind mount a volume' 342 | COMPGEN '-w' string 'Working directory inside the container' 343 | COMPGEN --workdir string 'Working directory inside the container' 344 | } 345 | 346 | Register-Completer docker_compose_scale -Option { 347 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 348 | COMPGEN --no-deps Switch 'Don''t start linked services' 349 | } 350 | 351 | Register-Completer docker_compose_stats -Option { 352 | COMPGEN '-a' Switch 'Show all containers (default shows just running)' 353 | COMPGEN --all Switch 'Show all containers (default shows just running)' 354 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 355 | COMPGEN --format string 'Format output using a custom template: 356 | ''table'': Print output in table format with column headers (default) 357 | ''table TEMPLATE'': Print output in table format using the given Go template 358 | ''json'': Print in JSON format 359 | ''TEMPLATE'': Print output using the given Go template. 360 | Refer to https://docs.docker.com/engine/cli/formatting/ for more information about formatting output with templates' 361 | COMPGEN --no-stream Switch 'Disable streaming stats and only pull the first result' 362 | COMPGEN --no-trunc Switch 'Do not truncate output' 363 | } 364 | 365 | Register-Completer docker_compose_stop -Option { 366 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 367 | COMPGEN '-t' int 'Specify a shutdown timeout in seconds' 368 | COMPGEN --timeout int 'Specify a shutdown timeout in seconds' 369 | } 370 | 371 | Register-Completer docker_compose_up -Option { 372 | COMPGEN --abort-on-container-exit Switch 'Stops all containers if any container was stopped. Incompatible with -d' 373 | COMPGEN --abort-on-container-failure Switch 'Stops all containers if any container exited with failure. Incompatible with -d' 374 | COMPGEN --always-recreate-deps Switch 'Recreate dependent containers. Incompatible with --no-recreate.' 375 | COMPGEN --attach stringArray 'Restrict attaching to the specified services. Incompatible with --attach-dependencies.' 376 | COMPGEN --attach-dependencies Switch 'Automatically attach to log output of dependent services' 377 | COMPGEN --build Switch 'Build images before starting containers' 378 | COMPGEN '-d' Switch 'Detached mode: Run containers in the background' 379 | COMPGEN --detach Switch 'Detached mode: Run containers in the background' 380 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 381 | COMPGEN --exit-code-from string 'Return the exit code of the selected service container. Implies --abort-on-container-exit' 382 | COMPGEN --force-recreate Switch 'Recreate containers even if their configuration and image haven''t changed' 383 | COMPGEN --menu Switch 'Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.' 384 | COMPGEN --no-attach stringArray 'Do not attach (stream logs) to the specified services' 385 | COMPGEN --no-build Switch 'Don''t build an image, even if it''s policy' 386 | COMPGEN --no-color Switch 'Produce monochrome output' 387 | COMPGEN --no-deps Switch 'Don''t start linked services' 388 | COMPGEN --no-log-prefix Switch 'Don''t print prefix in logs' 389 | COMPGEN --no-recreate Switch 'If containers already exist, don''t recreate them. Incompatible with --force-recreate.' 390 | COMPGEN --no-start Switch 'Don''t start the services after creating them' 391 | COMPGEN --pull string 'Pull image before running ("always"|"missing"|"never")' 392 | COMPGEN --quiet-pull Switch 'Pull without printing progress information' 393 | COMPGEN --remove-orphans Switch 'Remove containers for services not defined in the Compose file' 394 | COMPGEN '-V' Switch 'Recreate anonymous volumes instead of retrieving data from the previous containers' 395 | COMPGEN --renew-anon-volumes Switch 'Recreate anonymous volumes instead of retrieving data from the previous containers' 396 | COMPGEN --scale stringArray 'Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.' 397 | COMPGEN '-t' int 'Use this timeout in seconds for container shutdown when attached or when containers are already running' 398 | COMPGEN --timeout int 'Use this timeout in seconds for container shutdown when attached or when containers are already running' 399 | COMPGEN --timestamps Switch 'Show timestamps' 400 | COMPGEN --wait Switch 'Wait for services to be running|healthy. Implies detached mode.' 401 | COMPGEN --wait-timeout int 'Maximum duration in seconds to wait for the project to be running|healthy' 402 | COMPGEN '-w' Switch 'Watch source code and rebuild/refresh containers when files are updated.' 403 | COMPGEN --watch Switch 'Watch source code and rebuild/refresh containers when files are updated.' 404 | COMPGEN '-y' Switch 'Assume "yes" as answer to all prompts and run non-interactively' 405 | COMPGEN --yes Switch 'Assume "yes" as answer to all prompts and run non-interactively' 406 | } 407 | 408 | Register-Completer docker_compose_version -Option { 409 | COMPGEN '-f' string 'Format the output. Values: [pretty | json]. (Default: pretty)' 410 | COMPGEN --format string 'Format the output. Values: [pretty | json]. (Default: pretty)' 411 | COMPGEN --short Switch 'Shows only Compose''s version number' 412 | } 413 | 414 | Register-Completer docker_compose_wait -Option { 415 | COMPGEN --down-project Switch 'Drops project when the first container stops' 416 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 417 | } 418 | 419 | Register-Completer docker_compose_watch -Option { 420 | COMPGEN --dry-run Switch 'Execute command in dry run mode' 421 | COMPGEN --no-up Switch 'Do not build & start services before watching' 422 | COMPGEN --prune Switch 'Prune dangling images on rebuild' 423 | COMPGEN --quiet Switch 'hide build output' 424 | } 425 | -------------------------------------------------------------------------------- /DockerCompletion/Compose/completers4arguments.ps1: -------------------------------------------------------------------------------- 1 | $profileAll = { 2 | param ($WordToComplete, $CommandAst) 3 | 4 | $commandTextsOriginal = Get-ComposeCommandText -CommandAst $CommandAst 5 | $commandTexts = New-Object System.Collections.ArrayList 6 | 7 | # Remove all `--profile stringArray` 8 | # Because this scriptblock is used for `--profile` argument completion 9 | $ignoreNext = $false 10 | foreach ($text in $commandTextsOriginal) { 11 | if ($ignoreNext) { 12 | $ignoreNext = $false 13 | continue 14 | } 15 | 16 | if ($text -eq '--profile') { 17 | $ignoreNext = $true 18 | } else { 19 | $commandTexts.Add($text) > $null 20 | } 21 | } 22 | 23 | Invoke-Expression -Command ("{0} convert --profiles" -f ($commandTexts -join ' ')) | Sort-Object 24 | } 25 | 26 | $serviceAll = { 27 | param ($WordToComplete, $CommandAst) 28 | 29 | $commandTexts = Get-ComposeCommandText -CommandAst $CommandAst 30 | Invoke-Expression -Command ("{0} convert --services" -f ($commandTexts -join ' ')) | Sort-Object 31 | } 32 | 33 | $serviceRunning = { 34 | param ($WordToComplete, $CommandAst) 35 | 36 | $commandTexts = Get-ComposeCommandText -CommandAst $CommandAst 37 | $services = Invoke-Expression -Command ("{0} ps --format json --status running | ConvertFrom-Json" -f ($commandTexts -join ' ')) 38 | $services.Service | Sort-Object -Unique 39 | } 40 | 41 | $serviceStartable = { 42 | param ($WordToComplete, $CommandAst) 43 | 44 | $commandTexts = Get-ComposeCommandText -CommandAst $CommandAst 45 | # Multi-status, `--status created --status exited`, is prefered, but it does not work with Compose v2.0.0 46 | # See: https://github.com/docker/compose/issues/8700 47 | $services = Invoke-Expression -Command ("{0} ps --format json --all | ConvertFrom-Json" -f ($commandTexts -join ' ')) 48 | ($services | Where-Object State -In @('created', 'exited')).Service | Sort-Object -Unique 49 | } 50 | 51 | $servicePaused = { 52 | param ($WordToComplete, $CommandAst) 53 | 54 | $commandTexts = Get-ComposeCommandText -CommandAst $CommandAst 55 | $services = Invoke-Expression -Command ("{0} ps --format json --status paused | ConvertFrom-Json" -f ($commandTexts -join ' ')) 56 | $services.Service | Sort-Object -Unique 57 | } 58 | 59 | Register-Completer docker_compose_--ansi { 'always', 'auto', 'never' } 60 | Register-Completer docker_compose_--profile $profileAll 61 | Register-Completer docker_compose_--progress { 'auto', 'json', 'plain', 'quiet', 'tty' } 62 | Register-Completer docker_compose_build $serviceAll 63 | Register-Completer docker_compose_build_--progress { 'auto', 'json', 'plain', 'quiet', 'tty' } 64 | Register-Completer docker_compose_config_--format { 'json', 'yaml' } 65 | Register-Completer docker_compose_create $serviceAll 66 | Register-Completer docker_compose_create_--pull { 'always', 'build', 'missing', 'never' } 67 | Register-Completer docker_compose_down_--rmi { 'all', 'local' } 68 | Register-Completer docker_compose_events $serviceAll 69 | Register-Completer docker_compose_exec $serviceRunning 70 | Register-Completer docker_compose_images $serviceAll 71 | Register-Completer docker_compose_images_--format { 'json', 'table' } 72 | Register-Completer docker_compose_kill $serviceRunning 73 | Register-Completer docker_compose_kill_--signal { 74 | 'SIGCONT' 75 | 'SIGHUP' 76 | 'SIGINT' 77 | 'SIGKILL' 78 | 'SIGSTOP' 79 | 'SIGUSR1' 80 | 'SIGUSR2' 81 | } 82 | Register-Completer docker_compose_kill_-s (Get-Completer docker_compose_kill_--signal) 83 | Register-Completer docker_compose_logs $serviceAll 84 | Register-Completer docker_compose_ls_--format { 'json', 'table' } 85 | Register-Completer docker_compose_pause $serviceRunning 86 | Register-Completer docker_compose_port $serviceAll 87 | Register-Completer docker_compose_port_--protocol { 'tcp', 'udp' } 88 | Register-Completer docker_compose_ps $serviceAll 89 | Register-Completer docker_compose_ps_--format { 'json', 'table' } 90 | Register-Completer docker_compose_ps_--status { 'created', 'dead', 'exited', 'paused', 'removing', 'restarting', 'running' } 91 | Register-Completer docker_compose_pull $serviceAll 92 | Register-Completer docker_compose_push $serviceAll 93 | Register-Completer docker_compose_restart $serviceRunning 94 | Register-Completer docker_compose_rm $serviceAll 95 | Register-Completer docker_compose_run $serviceAll 96 | Register-Completer docker_compose_run_--pull { 'always', 'missing', 'never' } 97 | Register-Completer docker_compose_scale $serviceAll 98 | Register-Completer docker_compose_start $serviceStartable 99 | Register-Completer docker_compose_stop $serviceRunning 100 | Register-Completer docker_compose_top $serviceRunning 101 | Register-Completer docker_compose_unpause $servicePaused 102 | Register-Completer docker_compose_up $serviceAll 103 | Register-Completer docker_compose_up_--exit-code-from $serviceAll 104 | Register-Completer docker_compose_up_--pull { 'always', 'missing', 'never' } 105 | Register-Completer docker_compose_up_--scale $serviceAll 106 | Register-Completer docker_compose_version_--format { 'json', 'pretty' } 107 | Register-Completer docker_compose_version_-f (Get-Completer docker_compose_version_--format) 108 | -------------------------------------------------------------------------------- /DockerCompletion/DockerCompletion.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | 3 | RootModule = 'DockerCompletion.psm1' 4 | ModuleVersion = '1.2801.0.250503' 5 | GUID = '3c963cd2-8dce-445a-b7b7-778726965d7d' 6 | Author = 'Masatoshi Higuchi' 7 | CompanyName = 'N/A' 8 | Copyright = '(c) 2017-2025 Masatoshi Higuchi. All rights reserved.' 9 | Description = 'Docker command completion for PowerShell.' 10 | PowerShellVersion = '5.0' 11 | 12 | NestedModules = @( 13 | 'NativeCommandCompletion/NativeCommandCompletion.psd1' 14 | 'DockerCompletionUtility/DockerCompletionUtility.psd1' 15 | ) 16 | FunctionsToExport = @() 17 | CmdletsToExport = @() 18 | VariablesToExport = @() 19 | AliasesToExport = @() 20 | 21 | PrivateData = @{ PSData = @{ 22 | Tags = 'docker', 'completion' 23 | LicenseUri = 'https://github.com/matt9ucci/DockerCompletion/blob/master/LICENSE' 24 | ProjectUri = 'https://github.com/matt9ucci/DockerCompletion' 25 | ReleaseNotes = @' 26 | CLI v28.1.0 27 | Compose v2.35.1 28 | '@ 29 | } } 30 | 31 | DefaultCommandPrefix = 'Docker' 32 | 33 | } 34 | -------------------------------------------------------------------------------- /DockerCompletion/DockerCompletion.psm1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string[]]$CustomScriptPath 3 | ) 4 | 5 | function Select-CompletionResult { 6 | Param( 7 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 8 | [NativeCommandCompletionResult[]]$CompletionResult, 9 | [switch]$OptionWithArg, 10 | [switch]$LegacyOrTopLevelCommand, 11 | [switch]$SubCommand, 12 | [switch]$ManagementCommand 13 | ) 14 | 15 | Process { 16 | if ($OptionWithArg) { 17 | $CompletionResult = $CompletionResult | Where-Object { $_.CompletionText -Like '-*' -and $_.TextType -NE 'Switch' } 18 | } 19 | if ($LegacyOrTopLevelCommand) { 20 | $CompletionResult = $CompletionResult | Where-Object { $_.TextType -eq 'LegacyCommand' -or $_.TextType -eq 'TopLevelCommand' } 21 | } 22 | if ($SubCommand) { 23 | $CompletionResult = $CompletionResult | Where-Object TextType -EQ SubCommand 24 | } 25 | if ($ManagementCommand) { 26 | $CompletionResult = $CompletionResult | Where-Object TextType -EQ ManagementCommand 27 | } 28 | $CompletionResult 29 | } 30 | } 31 | 32 | function Invoke-CompletionCustomScript { 33 | Param( 34 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 35 | [string[]]$Path 36 | ) 37 | 38 | Process { 39 | foreach ($p in $Path) { 40 | . $p 41 | } 42 | } 43 | } 44 | 45 | function Get-ComposeCommandText { 46 | param ( 47 | $CommandAst 48 | ) 49 | 50 | $counter = 0 51 | $commandTexts = New-Object System.Collections.ArrayList 52 | 53 | foreach ($ce in $CommandAst.CommandElements) { 54 | $commandTexts.Add($ce.Extent.Text) > $null 55 | $counter++ 56 | if ($ce.Extent.Text -eq 'compose') { 57 | break 58 | } 59 | } 60 | # At this point, $commandTexts = @('docker', [OPTIONS]) 61 | 62 | $optionsWithArg = @( 63 | '-f', '--file' 64 | '--profile' 65 | '--project-directory' 66 | '-p', '--project-name' 67 | ) 68 | 69 | $addNext = $false 70 | for (; $counter -lt $CommandAst.CommandElements.Count; $counter++) { 71 | $text = $CommandAst.CommandElements[$counter].Extent.Text 72 | 73 | if ($addNext) { 74 | # option's argument (e.g. `file.yaml` of `-f file.yaml`) 75 | $commandTexts.Add($text) > $null 76 | $addNext = $false 77 | } elseif ($text -in $optionsWithArg) { 78 | $commandTexts.Add($text) > $null 79 | $addNext = $true 80 | } 81 | } 82 | # At this point, $commandTexts = @('docker', [OPTIONS], 'compose', [OPTIONS]) 83 | 84 | return $commandTexts 85 | } 86 | 87 | Invoke-CompletionCustomScript @( 88 | "$PSScriptRoot\completers.ps1" 89 | "$PSScriptRoot\completers4arguments.ps1" 90 | "$PSScriptRoot\Compose\completers.ps1" 91 | "$PSScriptRoot\Compose\completers4arguments.ps1" 92 | ) 93 | if ($CustomScriptPath) { 94 | Invoke-CompletionCustomScript $CustomScriptPath 95 | } 96 | 97 | $argumentCompleter = { 98 | Param([string]$wordToComplete, $commandAst, $cursorPosition) 99 | 100 | $completerName = 'docker' 101 | $optionWithArg = $null 102 | $managementCommand = $null 103 | $subCommand = $null 104 | $legacyOrTopLevelCommand = $null 105 | $indexOfFirstArg = -1 106 | $counter = 1 107 | 108 | for (; $counter -lt $commandAst.CommandElements.Count; $counter++) { 109 | $ce = $commandAst.CommandElements[$counter] 110 | if ($cursorPosition -lt $ce.Extent.EndColumnNumber) { 111 | break 112 | } 113 | 114 | if ($optionWithArg) { 115 | # The argument of $optionWithArg is completed by this $ce 116 | $optionWithArg = $null 117 | continue 118 | } 119 | 120 | $text = $ce.Extent.Text 121 | if ($text.StartsWith('-')) { 122 | if ($text -in (Invoke-Completer $completerName -Option -ArgumentList $wordToComplete, $commandAst, $cursorPosition | 123 | Select-CompletionResult -OptionWithArg).CompletionText) { 124 | $optionWithArg = $text 125 | } 126 | } elseif (!$managementCommand -and !$legacyOrTopLevelCommand) { 127 | if ($text -in (Invoke-Completer $completerName -Completer -ArgumentList $wordToComplete, $commandAst, $cursorPosition | 128 | Select-CompletionResult -LegacyOrTopLevelCommand).CompletionText) { 129 | $legacyOrTopLevelCommand = $text 130 | $completerName += "_$legacyOrTopLevelCommand" 131 | } else { 132 | $managementCommand = $text 133 | $completerName += "_$managementCommand" 134 | } 135 | } elseif ($managementCommand -and !$subCommand) { 136 | $results = Invoke-Completer $completerName -Completer -ArgumentList $wordToComplete, $commandAst, $cursorPosition 137 | if ($text -in ($results | Select-CompletionResult -SubCommand).CompletionText) { 138 | $subCommand = $text 139 | $completerName += "_$subCommand" 140 | } elseif ($text -in ($results | Select-CompletionResult -ManagementCommand).CompletionText) { 141 | $managementCommand = $text 142 | $completerName += "_$managementCommand" 143 | } 144 | } elseif ($indexOfFirstArg -lt 0) { 145 | $indexOfFirstArg = $counter 146 | } 147 | } 148 | 149 | if ($optionWithArg) { 150 | $completerName += "_$optionWithArg" 151 | } 152 | 153 | # At this point, $completerName is any of the following: 154 | # 'docker' 155 | # 'docker_optionWithArg' 156 | # 'docker_legacyOrTopLevelCommand' 157 | # 'docker_legacyOrTopLevelCommand_optionWithArg' 158 | # 'docker_managementCommand' 159 | # 'docker_managementCommand_subCommand' 160 | # 'docker_managementCommand_subCommand_optionWithArg' 161 | # These managementCommand can be followed by managementCommand (`trust` command) 162 | 163 | if ($wordToComplete) { 164 | $ceElements = $commandAst.CommandElements[$counter].Elements 165 | if ($ceElements) { 166 | # comma-separated args (e.g. `--mount type=bind,src=/c/Users/matt9ucci,dst=/root`) 167 | foreach ($cee in $ceElements) { 168 | if (($wordToComplete -eq $cee.Value) -and ($cursorPosition -ge $cee.Extent.StartOffset)) { 169 | $wordToCompleteSubstring = $wordToComplete.Substring(0, $cursorPosition - $cee.Extent.StartOffset) 170 | } 171 | } 172 | $wordToComplete = $wordToCompleteSubstring 173 | } else { 174 | $wordToCompleteSubstring = $wordToComplete.Substring(0, $cursorPosition - $commandAst.CommandElements[$counter].Extent.StartOffset) 175 | } 176 | } 177 | 178 | if ($wordToComplete.StartsWith('-')) { 179 | $completionResult = Invoke-Completer $completerName -Option -ArgumentList $wordToComplete, $commandAst, $cursorPosition 180 | } else { 181 | $completionResult = Invoke-Completer $completerName -Completer -ArgumentList $wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg 182 | } 183 | 184 | $completionResult | Where-Object CompletionText -Like "$wordToCompleteSubstring*" 185 | } 186 | 187 | Register-NativeCommandArgumentCompleter docker $argumentCompleter 188 | -------------------------------------------------------------------------------- /DockerCompletion/DockerCompletionUtility/DockerCompletionUtility.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | 3 | # Script module or binary module file associated with this manifest. 4 | RootModule = 'DockerCompletionUtility' 5 | 6 | # Version number of this module. 7 | ModuleVersion = '1.200618' 8 | 9 | # Supported PSEditions 10 | # CompatiblePSEditions = @() 11 | 12 | # ID used to uniquely identify this module 13 | GUID = 'f217037f-6edd-489e-86a8-b5e95d1c078c' 14 | 15 | # Author of this module 16 | Author = 'Masatoshi Higuchi' 17 | 18 | # Company or vendor of this module 19 | CompanyName = 'N/A' 20 | 21 | # Copyright statement for this module 22 | Copyright = '(c) 2020 Masatoshi Higuchi. All rights reserved.' 23 | 24 | # Description of the functionality provided by this module 25 | Description = 'Utility for DockerCompletion.' 26 | 27 | # Minimum version of the Windows PowerShell engine required by this module 28 | PowerShellVersion = '5.0' 29 | 30 | # Name of the Windows PowerShell host required by this module 31 | # PowerShellHostName = '' 32 | 33 | # Minimum version of the Windows PowerShell host required by this module 34 | # PowerShellHostVersion = '' 35 | 36 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 37 | # DotNetFrameworkVersion = '' 38 | 39 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 40 | # CLRVersion = '' 41 | 42 | # Processor architecture (None, X86, Amd64) required by this module 43 | # ProcessorArchitecture = '' 44 | 45 | # Modules that must be imported into the global environment prior to importing this module 46 | # RequiredModules = @() 47 | 48 | # Assemblies that must be loaded prior to importing this module 49 | # RequiredAssemblies = @() 50 | 51 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 52 | # ScriptsToProcess = @() 53 | 54 | # Type files (.ps1xml) to be loaded when importing this module 55 | # TypesToProcess = @() 56 | 57 | # Format files (.ps1xml) to be loaded when importing this module 58 | # FormatsToProcess = @() 59 | 60 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 61 | # NestedModules = @() 62 | 63 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 64 | FunctionsToExport = '*' 65 | 66 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 67 | CmdletsToExport = '*' 68 | 69 | # Variables to export from this module 70 | VariablesToExport = '*' 71 | 72 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 73 | AliasesToExport = '*' 74 | 75 | # DSC resources to export from this module 76 | # DscResourcesToExport = @() 77 | 78 | # List of all modules packaged with this module 79 | # ModuleList = @() 80 | 81 | # List of all files packaged with this module 82 | # FileList = @() 83 | 84 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 85 | PrivateData = @{ 86 | 87 | PSData = @{ 88 | 89 | # Tags applied to this module. These help with module discovery in online galleries. 90 | Tags = 'docker', 'completion' 91 | 92 | # A URL to the license for this module. 93 | LicenseUri = 'https://github.com/matt9ucci/DockerCompletion/blob/master/LICENSE' 94 | 95 | # A URL to the main website for this project. 96 | ProjectUri = 'https://github.com/matt9ucci/DockerCompletion' 97 | 98 | # A URL to an icon representing this module. 99 | # IconUri = '' 100 | 101 | # ReleaseNotes of this module 102 | # ReleaseNotes = '' 103 | 104 | } # End of PSData hashtable 105 | 106 | } # End of PrivateData hashtable 107 | 108 | # HelpInfo URI of this module 109 | # HelpInfoURI = '' 110 | 111 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 112 | # DefaultCommandPrefix = '' 113 | 114 | } 115 | 116 | -------------------------------------------------------------------------------- /DockerCompletion/DockerCompletionUtility/DockerCompletionUtility.psm1: -------------------------------------------------------------------------------- 1 | function Get-Config { 2 | docker config ls --format '{{.Name}}' 3 | } 4 | 5 | function Get-Container { 6 | Param( 7 | [ValidateSet('created', 'dead', 'exited', 'paused', 'removing', 'restarting', 'running')] 8 | [string[]]$Status 9 | ) 10 | 11 | $options = New-Object System.Collections.ArrayList 12 | if ($Status) { 13 | foreach ($s in $Status) { 14 | $options.Add("--filter 'status=$s'") > $null 15 | } 16 | } else { 17 | $options.Add('--all') > $null 18 | } 19 | 20 | $command = "docker container ls --format '{{{{.Names}}}}' {0}" -f ($options -join ' ') 21 | Invoke-Expression -Command $command 22 | } 23 | 24 | function Get-Context { 25 | docker context ls --quiet 26 | } 27 | 28 | function Get-Image { 29 | Param( 30 | [switch]$WithTag 31 | ) 32 | 33 | $sorted = docker image ls --format '{{.Repository}}:{{.Tag}}' | Sort-Object 34 | if (!$WithTag) { 35 | $sorted | Where-Object { $_ -like '*:latest' } | ForEach-Object { $_ -replace ':latest$' } | Get-Unique 36 | } 37 | $sorted | Where-Object { $_ -notlike '*:' } 38 | } 39 | 40 | function Get-ImageRepository { 41 | $sorted = docker image ls --format '{{.Repository}}:{{.Tag}}' | Sort-Object 42 | $sorted | Where-Object { $_ -notlike '*:' } | ForEach-Object { $_ -replace ':.*?$' } | Get-Unique 43 | } 44 | 45 | function Get-Network { 46 | Param( 47 | [ValidateSet('builtin', 'custom')] 48 | [string[]]$Type 49 | ) 50 | 51 | $options = New-Object System.Collections.ArrayList 52 | if ($Type) { 53 | foreach ($t in $Type) { 54 | $options.Add("--filter 'type=$t'") > $null 55 | } 56 | } 57 | 58 | $command = "docker network ls --format '{{{{.Name}}}}' {0}" -f ($options -join ' ') 59 | Invoke-Expression -Command $command 60 | } 61 | 62 | function Get-Node { 63 | Param( 64 | [ValidateSet('manager', 'worker')] 65 | [string[]]$Role 66 | ) 67 | 68 | $options = New-Object System.Collections.ArrayList 69 | if ($Role) { 70 | foreach ($r in $Role) { 71 | $options.Add("--filter 'role=$r'") > $null 72 | } 73 | } 74 | 75 | $command = "docker node ls --format '{{{{.Hostname}}}}' {0}" -f ($options -join ' ') 76 | Invoke-Expression -Command $command 77 | } 78 | 79 | function Get-Plugin { 80 | docker plugin ls --format '{{.Name}}' 81 | } 82 | 83 | function Get-Secret { 84 | docker secret ls --format '{{.Name}}' 85 | } 86 | 87 | function Get-Service { 88 | docker service ls --format '{{.Name}}' 89 | } 90 | 91 | function Get-Volume { 92 | docker volume ls --quiet 93 | } 94 | -------------------------------------------------------------------------------- /DockerCompletion/NativeCommandCompletion/NativeCommandCompletion.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | 3 | # Script module or binary module file associated with this manifest. 4 | RootModule = 'NativeCommandCompletion' 5 | 6 | # Version number of this module. 7 | ModuleVersion = '1.180815' 8 | 9 | # ID used to uniquely identify this module 10 | GUID = 'de6408b5-8f0e-417f-a0ee-dab89c4737bf' 11 | 12 | # Author of this module 13 | Author = 'Masatoshi Higuchi' 14 | 15 | # Company or vendor of this module 16 | CompanyName = 'N/A' 17 | 18 | # Copyright statement for this module 19 | Copyright = '(c) 2018 Masatoshi Higuchi. All rights reserved.' 20 | 21 | # Description of the functionality provided by this module 22 | Description = 'Native command completion module.' 23 | 24 | # Minimum version of the Windows PowerShell engine required by this module 25 | PowerShellVersion = '5.0' 26 | 27 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 28 | FunctionsToExport = '*' 29 | 30 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 31 | CmdletsToExport = '*' 32 | 33 | # Variables to export from this module 34 | VariablesToExport = '*' 35 | 36 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 37 | AliasesToExport = '*' 38 | 39 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 40 | PrivateData = @{ 41 | 42 | PSData = @{ 43 | 44 | # Tags applied to this module. These help with module discovery in online galleries. 45 | Tags = 'native', 'completion' 46 | 47 | # A URL to the license for this module. 48 | LicenseUri = 'https://github.com/matt9ucci/DockerCompletion/blob/master/LICENSE' 49 | 50 | # A URL to the main website for this project. 51 | ProjectUri = 'https://github.com/matt9ucci/DockerCompletion' 52 | 53 | } # End of PSData hashtable 54 | 55 | } # End of PrivateData hashtable 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /DockerCompletion/NativeCommandCompletion/NativeCommandCompletion.psm1: -------------------------------------------------------------------------------- 1 | class NativeCommandCompletionResult : System.Management.Automation.CompletionResult { 2 | [string]$TextType 3 | 4 | NativeCommandCompletionResult( 5 | [string]$CompletionText, 6 | [string]$ListItemText, 7 | [System.Management.Automation.CompletionResultType]$ResultType, 8 | [string]$ToolTip, 9 | [string]$TextType) : 10 | base($CompletionText, $ListItemText, $ResultType, $ToolTip) { 11 | 12 | $this.TextType = $TextType 13 | } 14 | } 15 | 16 | $nativeCommandCompleters = @{} 17 | 18 | function New-CompletionResult { 19 | param ( 20 | [Parameter(Mandatory)] 21 | [string]$CompletionText, 22 | [string]$TextType, 23 | [string]$ToolTip = $CompletionText, 24 | [string]$ListItemText = $CompletionText, 25 | [System.Management.Automation.CompletionResultType]$ResultType 26 | ) 27 | 28 | if (!$ResultType) { 29 | if ($CompletionText.StartsWith('-')) { 30 | $ResultType = [System.Management.Automation.CompletionResultType]::ParameterName 31 | } elseif ($TextType -like '*Command') { 32 | $ResultType = [System.Management.Automation.CompletionResultType]::Command 33 | } else { 34 | $ResultType = [System.Management.Automation.CompletionResultType]::Text 35 | } 36 | } 37 | 38 | New-Object NativeCommandCompletionResult $CompletionText, $ListItemText, $ResultType, $ToolTip, $TextType 39 | } 40 | 41 | Set-Alias -Name COMPGEN -Value New-CompletionResult 42 | 43 | function Register-Completer { 44 | param ( 45 | [Parameter(Mandatory)] 46 | [string]$Name, 47 | $Completer, 48 | [Alias('Option')] 49 | $Parameter 50 | ) 51 | 52 | if (!$nativeCommandCompleters.ContainsKey($Name)) { 53 | $nativeCommandCompleters[$Name] = @{} 54 | } 55 | 56 | if ($Completer) { 57 | $nativeCommandCompleters[$Name].completer = $Completer 58 | } 59 | if ($Parameter) { 60 | $nativeCommandCompleters[$Name].parameter = $Parameter 61 | } 62 | } 63 | 64 | function Get-Completer { 65 | param ( 66 | [Parameter(Mandatory)] 67 | [string]$Name, 68 | [Alias('Option')] 69 | [switch]$Parameter 70 | ) 71 | 72 | if ($Parameter) { 73 | $nativeCommandCompleters[$Name].parameter 74 | } else { 75 | $nativeCommandCompleters[$Name].completer 76 | } 77 | } 78 | 79 | function Invoke-Completer { 80 | param ( 81 | [Parameter(Mandatory, Position = 0)] 82 | [string]$Name, 83 | [Parameter(Mandatory, ParameterSetName = 'Completer')] 84 | [switch]$Completer, 85 | [Parameter(Mandatory, ParameterSetName = 'Parameter')] 86 | [Alias('Option')] 87 | [switch]$Parameter, 88 | [Object[]]$ArgumentList 89 | ) 90 | 91 | $cmpltr = switch ($PSCmdlet.ParameterSetName) { 92 | Completer { $nativeCommandCompleters[$Name].completer } 93 | Parameter { $nativeCommandCompleters[$Name].parameter } 94 | } 95 | 96 | if ($cmpltr -is [scriptblock]) { 97 | $cmpltr = Invoke-Command -ScriptBlock $cmpltr -ArgumentList $ArgumentList 98 | } 99 | 100 | foreach ($c in $cmpltr) { 101 | if ($c -is [NativeCommandCompletionResult]) { 102 | $c 103 | } else { 104 | New-CompletionResult -CompletionText $c -TextType Text -ResultType ([System.Management.Automation.CompletionResultType]::Text) 105 | } 106 | } 107 | } 108 | 109 | function Register-NativeCommandArgumentCompleter { 110 | param ( 111 | [Parameter(Mandatory)] 112 | [string]$CommandName, 113 | [Parameter(Mandatory)] 114 | [scriptblock]$ScriptBlock 115 | ) 116 | 117 | $CommandName, (Get-Alias -Definition $CommandName -ErrorAction Ignore).Name | ForEach-Object { 118 | if ($_) { 119 | Register-ArgumentCompleter -CommandName $_ -ScriptBlock $ScriptBlock -Native 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /DockerCompletion/OSSLICENSES.txt: -------------------------------------------------------------------------------- 1 | DockerCompletion has a feature to show tool tip texts. 2 | These texts are copied or modified texts of [Docker CLI](https://github.com/docker/cli) and [Docker Compose](https://github.com/docker/compose). 3 | 4 | The following is a copy of the Docker CLI license. 5 | 6 | **************** Docker CLI license begins here **************** 7 | 8 | Apache License 9 | Version 2.0, January 2004 10 | https://www.apache.org/licenses/ 11 | 12 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 13 | 14 | 1. Definitions. 15 | 16 | "License" shall mean the terms and conditions for use, reproduction, 17 | and distribution as defined by Sections 1 through 9 of this document. 18 | 19 | "Licensor" shall mean the copyright owner or entity authorized by 20 | the copyright owner that is granting the License. 21 | 22 | "Legal Entity" shall mean the union of the acting entity and all 23 | other entities that control, are controlled by, or are under common 24 | control with that entity. For the purposes of this definition, 25 | "control" means (i) the power, direct or indirect, to cause the 26 | direction or management of such entity, whether by contract or 27 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 28 | outstanding shares, or (iii) beneficial ownership of such entity. 29 | 30 | "You" (or "Your") shall mean an individual or Legal Entity 31 | exercising permissions granted by this License. 32 | 33 | "Source" form shall mean the preferred form for making modifications, 34 | including but not limited to software source code, documentation 35 | source, and configuration files. 36 | 37 | "Object" form shall mean any form resulting from mechanical 38 | transformation or translation of a Source form, including but 39 | not limited to compiled object code, generated documentation, 40 | and conversions to other media types. 41 | 42 | "Work" shall mean the work of authorship, whether in Source or 43 | Object form, made available under the License, as indicated by a 44 | copyright notice that is included in or attached to the work 45 | (an example is provided in the Appendix below). 46 | 47 | "Derivative Works" shall mean any work, whether in Source or Object 48 | form, that is based on (or derived from) the Work and for which the 49 | editorial revisions, annotations, elaborations, or other modifications 50 | represent, as a whole, an original work of authorship. For the purposes 51 | of this License, Derivative Works shall not include works that remain 52 | separable from, or merely link (or bind by name) to the interfaces of, 53 | the Work and Derivative Works thereof. 54 | 55 | "Contribution" shall mean any work of authorship, including 56 | the original version of the Work and any modifications or additions 57 | to that Work or Derivative Works thereof, that is intentionally 58 | submitted to Licensor for inclusion in the Work by the copyright owner 59 | or by an individual or Legal Entity authorized to submit on behalf of 60 | the copyright owner. For the purposes of this definition, "submitted" 61 | means any form of electronic, verbal, or written communication sent 62 | to the Licensor or its representatives, including but not limited to 63 | communication on electronic mailing lists, source code control systems, 64 | and issue tracking systems that are managed by, or on behalf of, the 65 | Licensor for the purpose of discussing and improving the Work, but 66 | excluding communication that is conspicuously marked or otherwise 67 | designated in writing by the copyright owner as "Not a Contribution." 68 | 69 | "Contributor" shall mean Licensor and any individual or Legal Entity 70 | on behalf of whom a Contribution has been received by Licensor and 71 | subsequently incorporated within the Work. 72 | 73 | 2. Grant of Copyright License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | copyright license to reproduce, prepare Derivative Works of, 77 | publicly display, publicly perform, sublicense, and distribute the 78 | Work and such Derivative Works in Source or Object form. 79 | 80 | 3. Grant of Patent License. Subject to the terms and conditions of 81 | this License, each Contributor hereby grants to You a perpetual, 82 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 83 | (except as stated in this section) patent license to make, have made, 84 | use, offer to sell, sell, import, and otherwise transfer the Work, 85 | where such license applies only to those patent claims licensable 86 | by such Contributor that are necessarily infringed by their 87 | Contribution(s) alone or by combination of their Contribution(s) 88 | with the Work to which such Contribution(s) was submitted. If You 89 | institute patent litigation against any entity (including a 90 | cross-claim or counterclaim in a lawsuit) alleging that the Work 91 | or a Contribution incorporated within the Work constitutes direct 92 | or contributory patent infringement, then any patent licenses 93 | granted to You under this License for that Work shall terminate 94 | as of the date such litigation is filed. 95 | 96 | 4. Redistribution. You may reproduce and distribute copies of the 97 | Work or Derivative Works thereof in any medium, with or without 98 | modifications, and in Source or Object form, provided that You 99 | meet the following conditions: 100 | 101 | (a) You must give any other recipients of the Work or 102 | Derivative Works a copy of this License; and 103 | 104 | (b) You must cause any modified files to carry prominent notices 105 | stating that You changed the files; and 106 | 107 | (c) You must retain, in the Source form of any Derivative Works 108 | that You distribute, all copyright, patent, trademark, and 109 | attribution notices from the Source form of the Work, 110 | excluding those notices that do not pertain to any part of 111 | the Derivative Works; and 112 | 113 | (d) If the Work includes a "NOTICE" text file as part of its 114 | distribution, then any Derivative Works that You distribute must 115 | include a readable copy of the attribution notices contained 116 | within such NOTICE file, excluding those notices that do not 117 | pertain to any part of the Derivative Works, in at least one 118 | of the following places: within a NOTICE text file distributed 119 | as part of the Derivative Works; within the Source form or 120 | documentation, if provided along with the Derivative Works; or, 121 | within a display generated by the Derivative Works, if and 122 | wherever such third-party notices normally appear. The contents 123 | of the NOTICE file are for informational purposes only and 124 | do not modify the License. You may add Your own attribution 125 | notices within Derivative Works that You distribute, alongside 126 | or as an addendum to the NOTICE text from the Work, provided 127 | that such additional attribution notices cannot be construed 128 | as modifying the License. 129 | 130 | You may add Your own copyright statement to Your modifications and 131 | may provide additional or different license terms and conditions 132 | for use, reproduction, or distribution of Your modifications, or 133 | for any such Derivative Works as a whole, provided Your use, 134 | reproduction, and distribution of the Work otherwise complies with 135 | the conditions stated in this License. 136 | 137 | 5. Submission of Contributions. Unless You explicitly state otherwise, 138 | any Contribution intentionally submitted for inclusion in the Work 139 | by You to the Licensor shall be under the terms and conditions of 140 | this License, without any additional terms or conditions. 141 | Notwithstanding the above, nothing herein shall supersede or modify 142 | the terms of any separate license agreement you may have executed 143 | with Licensor regarding such Contributions. 144 | 145 | 6. Trademarks. This License does not grant permission to use the trade 146 | names, trademarks, service marks, or product names of the Licensor, 147 | except as required for reasonable and customary use in describing the 148 | origin of the Work and reproducing the content of the NOTICE file. 149 | 150 | 7. Disclaimer of Warranty. Unless required by applicable law or 151 | agreed to in writing, Licensor provides the Work (and each 152 | Contributor provides its Contributions) on an "AS IS" BASIS, 153 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 154 | implied, including, without limitation, any warranties or conditions 155 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 156 | PARTICULAR PURPOSE. You are solely responsible for determining the 157 | appropriateness of using or redistributing the Work and assume any 158 | risks associated with Your exercise of permissions under this License. 159 | 160 | 8. Limitation of Liability. In no event and under no legal theory, 161 | whether in tort (including negligence), contract, or otherwise, 162 | unless required by applicable law (such as deliberate and grossly 163 | negligent acts) or agreed to in writing, shall any Contributor be 164 | liable to You for damages, including any direct, indirect, special, 165 | incidental, or consequential damages of any character arising as a 166 | result of this License or out of the use or inability to use the 167 | Work (including but not limited to damages for loss of goodwill, 168 | work stoppage, computer failure or malfunction, or any and all 169 | other commercial damages or losses), even if such Contributor 170 | has been advised of the possibility of such damages. 171 | 172 | 9. Accepting Warranty or Additional Liability. While redistributing 173 | the Work or Derivative Works thereof, You may choose to offer, 174 | and charge a fee for, acceptance of support, warranty, indemnity, 175 | or other liability obligations and/or rights consistent with this 176 | License. However, in accepting such obligations, You may act only 177 | on Your own behalf and on Your sole responsibility, not on behalf 178 | of any other Contributor, and only if You agree to indemnify, 179 | defend, and hold each Contributor harmless for any liability 180 | incurred by, or claims asserted against, such Contributor by reason 181 | of your accepting any such warranty or additional liability. 182 | 183 | END OF TERMS AND CONDITIONS 184 | 185 | Copyright 2013-2017 Docker, Inc. 186 | 187 | Licensed under the Apache License, Version 2.0 (the "License"); 188 | you may not use this file except in compliance with the License. 189 | You may obtain a copy of the License at 190 | 191 | https://www.apache.org/licenses/LICENSE-2.0 192 | 193 | Unless required by applicable law or agreed to in writing, software 194 | distributed under the License is distributed on an "AS IS" BASIS, 195 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 196 | See the License for the specific language governing permissions and 197 | limitations under the License. 198 | **************** Docker CLI license ends here **************** 199 | 200 | The following is a copy of the Docker CLI NOTICE. 201 | 202 | **************** Docker CLI NOTICE begins here **************** 203 | Docker 204 | Copyright 2012-2017 Docker, Inc. 205 | 206 | This product includes software developed at Docker, Inc. (https://www.docker.com). 207 | 208 | This product contains software (https://github.com/creack/pty) developed 209 | by Keith Rarick, licensed under the MIT License. 210 | 211 | The following is courtesy of our legal counsel: 212 | 213 | 214 | Use and transfer of Docker may be subject to certain restrictions by the 215 | United States and other governments. 216 | It is your responsibility to ensure that your use and/or transfer does not 217 | violate applicable laws. 218 | 219 | For more information, please see https://www.bis.doc.gov 220 | 221 | See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. 222 | **************** Docker CLI NOTICE ends here **************** 223 | 224 | The following is a copy of the Docker Compose license. 225 | 226 | **************** Docker Compose license begins here **************** 227 | 228 | Apache License 229 | Version 2.0, January 2004 230 | http://www.apache.org/licenses/ 231 | 232 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 233 | 234 | 1. Definitions. 235 | 236 | "License" shall mean the terms and conditions for use, reproduction, 237 | and distribution as defined by Sections 1 through 9 of this document. 238 | 239 | "Licensor" shall mean the copyright owner or entity authorized by 240 | the copyright owner that is granting the License. 241 | 242 | "Legal Entity" shall mean the union of the acting entity and all 243 | other entities that control, are controlled by, or are under common 244 | control with that entity. For the purposes of this definition, 245 | "control" means (i) the power, direct or indirect, to cause the 246 | direction or management of such entity, whether by contract or 247 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 248 | outstanding shares, or (iii) beneficial ownership of such entity. 249 | 250 | "You" (or "Your") shall mean an individual or Legal Entity 251 | exercising permissions granted by this License. 252 | 253 | "Source" form shall mean the preferred form for making modifications, 254 | including but not limited to software source code, documentation 255 | source, and configuration files. 256 | 257 | "Object" form shall mean any form resulting from mechanical 258 | transformation or translation of a Source form, including but 259 | not limited to compiled object code, generated documentation, 260 | and conversions to other media types. 261 | 262 | "Work" shall mean the work of authorship, whether in Source or 263 | Object form, made available under the License, as indicated by a 264 | copyright notice that is included in or attached to the work 265 | (an example is provided in the Appendix below). 266 | 267 | "Derivative Works" shall mean any work, whether in Source or Object 268 | form, that is based on (or derived from) the Work and for which the 269 | editorial revisions, annotations, elaborations, or other modifications 270 | represent, as a whole, an original work of authorship. For the purposes 271 | of this License, Derivative Works shall not include works that remain 272 | separable from, or merely link (or bind by name) to the interfaces of, 273 | the Work and Derivative Works thereof. 274 | 275 | "Contribution" shall mean any work of authorship, including 276 | the original version of the Work and any modifications or additions 277 | to that Work or Derivative Works thereof, that is intentionally 278 | submitted to Licensor for inclusion in the Work by the copyright owner 279 | or by an individual or Legal Entity authorized to submit on behalf of 280 | the copyright owner. For the purposes of this definition, "submitted" 281 | means any form of electronic, verbal, or written communication sent 282 | to the Licensor or its representatives, including but not limited to 283 | communication on electronic mailing lists, source code control systems, 284 | and issue tracking systems that are managed by, or on behalf of, the 285 | Licensor for the purpose of discussing and improving the Work, but 286 | excluding communication that is conspicuously marked or otherwise 287 | designated in writing by the copyright owner as "Not a Contribution." 288 | 289 | "Contributor" shall mean Licensor and any individual or Legal Entity 290 | on behalf of whom a Contribution has been received by Licensor and 291 | subsequently incorporated within the Work. 292 | 293 | 2. Grant of Copyright License. Subject to the terms and conditions of 294 | this License, each Contributor hereby grants to You a perpetual, 295 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 296 | copyright license to reproduce, prepare Derivative Works of, 297 | publicly display, publicly perform, sublicense, and distribute the 298 | Work and such Derivative Works in Source or Object form. 299 | 300 | 3. Grant of Patent License. Subject to the terms and conditions of 301 | this License, each Contributor hereby grants to You a perpetual, 302 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 303 | (except as stated in this section) patent license to make, have made, 304 | use, offer to sell, sell, import, and otherwise transfer the Work, 305 | where such license applies only to those patent claims licensable 306 | by such Contributor that are necessarily infringed by their 307 | Contribution(s) alone or by combination of their Contribution(s) 308 | with the Work to which such Contribution(s) was submitted. If You 309 | institute patent litigation against any entity (including a 310 | cross-claim or counterclaim in a lawsuit) alleging that the Work 311 | or a Contribution incorporated within the Work constitutes direct 312 | or contributory patent infringement, then any patent licenses 313 | granted to You under this License for that Work shall terminate 314 | as of the date such litigation is filed. 315 | 316 | 4. Redistribution. You may reproduce and distribute copies of the 317 | Work or Derivative Works thereof in any medium, with or without 318 | modifications, and in Source or Object form, provided that You 319 | meet the following conditions: 320 | 321 | (a) You must give any other recipients of the Work or 322 | Derivative Works a copy of this License; and 323 | 324 | (b) You must cause any modified files to carry prominent notices 325 | stating that You changed the files; and 326 | 327 | (c) You must retain, in the Source form of any Derivative Works 328 | that You distribute, all copyright, patent, trademark, and 329 | attribution notices from the Source form of the Work, 330 | excluding those notices that do not pertain to any part of 331 | the Derivative Works; and 332 | 333 | (d) If the Work includes a "NOTICE" text file as part of its 334 | distribution, then any Derivative Works that You distribute must 335 | include a readable copy of the attribution notices contained 336 | within such NOTICE file, excluding those notices that do not 337 | pertain to any part of the Derivative Works, in at least one 338 | of the following places: within a NOTICE text file distributed 339 | as part of the Derivative Works; within the Source form or 340 | documentation, if provided along with the Derivative Works; or, 341 | within a display generated by the Derivative Works, if and 342 | wherever such third-party notices normally appear. The contents 343 | of the NOTICE file are for informational purposes only and 344 | do not modify the License. You may add Your own attribution 345 | notices within Derivative Works that You distribute, alongside 346 | or as an addendum to the NOTICE text from the Work, provided 347 | that such additional attribution notices cannot be construed 348 | as modifying the License. 349 | 350 | You may add Your own copyright statement to Your modifications and 351 | may provide additional or different license terms and conditions 352 | for use, reproduction, or distribution of Your modifications, or 353 | for any such Derivative Works as a whole, provided Your use, 354 | reproduction, and distribution of the Work otherwise complies with 355 | the conditions stated in this License. 356 | 357 | 5. Submission of Contributions. Unless You explicitly state otherwise, 358 | any Contribution intentionally submitted for inclusion in the Work 359 | by You to the Licensor shall be under the terms and conditions of 360 | this License, without any additional terms or conditions. 361 | Notwithstanding the above, nothing herein shall supersede or modify 362 | the terms of any separate license agreement you may have executed 363 | with Licensor regarding such Contributions. 364 | 365 | 6. Trademarks. This License does not grant permission to use the trade 366 | names, trademarks, service marks, or product names of the Licensor, 367 | except as required for reasonable and customary use in describing the 368 | origin of the Work and reproducing the content of the NOTICE file. 369 | 370 | 7. Disclaimer of Warranty. Unless required by applicable law or 371 | agreed to in writing, Licensor provides the Work (and each 372 | Contributor provides its Contributions) on an "AS IS" BASIS, 373 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 374 | implied, including, without limitation, any warranties or conditions 375 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 376 | PARTICULAR PURPOSE. You are solely responsible for determining the 377 | appropriateness of using or redistributing the Work and assume any 378 | risks associated with Your exercise of permissions under this License. 379 | 380 | 8. Limitation of Liability. In no event and under no legal theory, 381 | whether in tort (including negligence), contract, or otherwise, 382 | unless required by applicable law (such as deliberate and grossly 383 | negligent acts) or agreed to in writing, shall any Contributor be 384 | liable to You for damages, including any direct, indirect, special, 385 | incidental, or consequential damages of any character arising as a 386 | result of this License or out of the use or inability to use the 387 | Work (including but not limited to damages for loss of goodwill, 388 | work stoppage, computer failure or malfunction, or any and all 389 | other commercial damages or losses), even if such Contributor 390 | has been advised of the possibility of such damages. 391 | 392 | 9. Accepting Warranty or Additional Liability. While redistributing 393 | the Work or Derivative Works thereof, You may choose to offer, 394 | and charge a fee for, acceptance of support, warranty, indemnity, 395 | or other liability obligations and/or rights consistent with this 396 | License. However, in accepting such obligations, You may act only 397 | on Your own behalf and on Your sole responsibility, not on behalf 398 | of any other Contributor, and only if You agree to indemnify, 399 | defend, and hold each Contributor harmless for any liability 400 | incurred by, or claims asserted against, such Contributor by reason 401 | of your accepting any such warranty or additional liability. 402 | 403 | END OF TERMS AND CONDITIONS 404 | 405 | APPENDIX: How to apply the Apache License to your work. 406 | 407 | To apply the Apache License to your work, attach the following 408 | boilerplate notice, with the fields enclosed by brackets "[]" 409 | replaced with your own identifying information. (Don't include 410 | the brackets!) The text should be enclosed in the appropriate 411 | comment syntax for the file format. We also recommend that a 412 | file or class name and description of purpose be included on the 413 | same "printed page" as the copyright notice for easier 414 | identification within third-party archives. 415 | 416 | Copyright [yyyy] [name of copyright owner] 417 | 418 | Licensed under the Apache License, Version 2.0 (the "License"); 419 | you may not use this file except in compliance with the License. 420 | You may obtain a copy of the License at 421 | 422 | http://www.apache.org/licenses/LICENSE-2.0 423 | 424 | Unless required by applicable law or agreed to in writing, software 425 | distributed under the License is distributed on an "AS IS" BASIS, 426 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 427 | See the License for the specific language governing permissions and 428 | limitations under the License. 429 | **************** Docker Compose license ends here **************** 430 | 431 | The following is a copy of the Docker Compose NOTICE. 432 | 433 | **************** Docker Compose NOTICE begins here **************** 434 | Docker Compose V2 435 | Copyright 2020 Docker Compose authors 436 | 437 | This product includes software developed at Docker, Inc. (https://www.docker.com). 438 | **************** Docker Compose NOTICE ends here **************** 439 | -------------------------------------------------------------------------------- /DockerCompletion/completers4arguments.ps1: -------------------------------------------------------------------------------- 1 | $configAll = { Get-Config } 2 | 3 | $containerAll = { Get-Container } 4 | $containerRunning = { Get-Container -Status running } 5 | 6 | $contextAll = { Get-Context } 7 | 8 | $formatBasic = @("'{{json .}}'") 9 | 10 | $isolation = { 'default', 'hyperv', 'process' } 11 | 12 | $logDriver = { 13 | 'awslogs' 14 | 'etwlogs' 15 | 'fluentd' 16 | 'gcplogs' 17 | 'gelf' 18 | 'journald' 19 | 'json-file' 20 | 'local' 21 | 'logentries' 22 | 'none' 23 | 'splunk' 24 | 'syslog' 25 | } 26 | 27 | $networkAll = { Get-Network } 28 | 29 | $imageAll = { Get-Image } 30 | 31 | $serviceAll = { Get-Service } 32 | 33 | $stackAll = { docker stack ls --format '{{.Name}}' } 34 | 35 | $volumeAll = { Get-Volume } 36 | $volumeCluster = { docker volume ls --quiet --cluster } 37 | 38 | $capAddable = { 39 | COMPGEN ALL string 'All capabilities' 40 | COMPGEN AUDIT_CONTROL string 'Enable and disable kernel auditing; change auditing filter rules; retrieve auditing status and filtering rules' 41 | COMPGEN AUDIT_READ string 'Allow reading the audit log via multicast netlink socket' 42 | COMPGEN BLOCK_SUSPEND string 'Employ features that can block system suspend' 43 | COMPGEN BPF string 'Allow creating BPF maps, loading BPF Type Format (BTF) data, retrieve JITed code of BPF programs, and more' 44 | COMPGEN CHECKPOINT_RESTORE string 'Allow checkpoint/restore related operations. Introduced in kernel 5.9' 45 | COMPGEN DAC_READ_SEARCH string 'Bypass file read permission checks and directory read and execute permission checks' 46 | COMPGEN IPC_LOCK string 'Lock memory (mlock(2), mlockall(2), mmap(2), shmctl(2))' 47 | COMPGEN IPC_OWNER string 'Bypass permission checks for operations on System V IPC objects' 48 | COMPGEN LEASE string 'Establish leases on arbitrary files (see fcntl(2))' 49 | COMPGEN LINUX_IMMUTABLE string 'Set the FS_APPEND_FL and FS_IMMUTABLE_FL i-node flags' 50 | COMPGEN MAC_ADMIN string 'Override Mandatory Access Control (MAC). Implemented for the Smack Linux Security Module (LSM)' 51 | COMPGEN MAC_OVERRIDE string 'Allow MAC configuration or state changes. Implemented for the Smack LSM' 52 | COMPGEN NET_ADMIN string 'Perform various network-related operations' 53 | COMPGEN NET_BROADCAST string 'Make socket broadcasts, and listen to multicasts' 54 | COMPGEN PERFMON string 'Allow system performance and observability privileged operations using perf_events, i915_perf and other kernel subsystems' 55 | COMPGEN SYS_ADMIN string 'Perform a range of system administration operations' 56 | COMPGEN SYS_BOOT string 'Use reboot(2) and kexec_load(2), reboot and load a new kernel for later execution' 57 | COMPGEN SYS_MODULE string 'Load and unload kernel modules' 58 | COMPGEN SYS_NICE string 'Raise process nice value (nice(2), setpriority(2)) and change the nice value for arbitrary processes' 59 | COMPGEN SYS_PACCT string 'Use acct(2), switch process accounting on or off' 60 | COMPGEN SYS_PTRACE string 'Trace arbitrary processes using ptrace(2)' 61 | COMPGEN SYS_RAWIO string 'Perform I/O port operations (iopl(2) and ioperm(2))' 62 | COMPGEN SYS_RESOURCE string 'Override resource Limits' 63 | COMPGEN SYS_TIME string 'Set system clock (settimeofday(2), stime(2), adjtimex(2)); set real-time (hardware) clock' 64 | COMPGEN SYS_TTY_CONFIG string 'Use vhangup(2); employ various privileged ioctl(2) operations on virtual terminals' 65 | COMPGEN SYSLOG string 'Perform privileged syslog(2) operations' 66 | COMPGEN WAKE_ALARM string 'Trigger something that will wake up the system' 67 | } 68 | 69 | $capDroppable = { 70 | COMPGEN ALL string 'All capabilities' 71 | COMPGEN AUDIT_WRITE string 'Write records to kernel auditing log' 72 | COMPGEN CHOWN string 'Make arbitrary changes to file UIDs and GIDs (see chown(2))' 73 | COMPGEN DAC_OVERRIDE string 'Bypass file read, write, and execute permission checks' 74 | COMPGEN FOWNER string 'Bypass permission checks on operations that normally require the file system UID of the process to match the UID of the file' 75 | COMPGEN FSETID string 'Don''t clear set-user-ID and set-group-ID permission bits when a file is modified' 76 | COMPGEN KILL string 'Bypass permission checks for sending signals' 77 | COMPGEN MKNOD string 'Create special files using mknod(2)' 78 | COMPGEN NET_BIND_SERVICE string 'Bind a socket to internet domain privileged ports (port numbers less than 1024)' 79 | COMPGEN NET_RAW string 'Use RAW and PACKET sockets' 80 | COMPGEN SETFCAP string 'Set file capabilities' 81 | COMPGEN SETGID string 'Make arbitrary manipulations of process GIDs and supplementary GID list' 82 | COMPGEN SETPCAP string 'Modify process capabilities' 83 | COMPGEN SETUID string 'Make arbitrary manipulations of process UIDs' 84 | COMPGEN SYS_CHROOT string 'Use chroot(2), change root directory' 85 | } 86 | 87 | $platform = { 88 | 'linux' 89 | 'linux/386' 90 | 'linux/amd64' 91 | 'linux/arm' 92 | 'linux/arm/v5' 93 | 'linux/arm/v6' 94 | 'linux/arm/v7' 95 | 'linux/arm64' 96 | 'linux/arm64/v8' 97 | 'linux/ppc64le' 98 | 'linux/riscv64' 99 | 'linux/s390x' 100 | 'wasip1' 101 | 'wasip1/wasm' 102 | 'windows' 103 | 'windows/amd64' 104 | } 105 | 106 | $mount = { 107 | Param($wordToComplete, $commandAst, $cursorPosition) 108 | 109 | # Get type 110 | foreach ($keyValue in ($commandAst.CommandElements[-1] -split ',')) { 111 | $key, $value = $keyValue -split '=' 112 | if ($key -eq 'type') { 113 | $type = $value 114 | } 115 | } 116 | 117 | if (!$type) { 118 | $type = 'volume' # Default type 119 | COMPGEN type string 'The type of mount' 120 | } 121 | 122 | if ($wordToComplete -notlike '*=*') { 123 | switch ($type) { 124 | bind { 125 | COMPGEN source string 'The source of mount' 126 | COMPGEN src string 'The abbreviation of "source"' 127 | COMPGEN destination string 'The destination of mount' 128 | COMPGEN dst string 'The abbreviation of "destination"' 129 | COMPGEN target string 'The alias of "destination"' 130 | COMPGEN readonly string 'true or 1 or no value: readonly, false or 0: read-write' 131 | COMPGEN ro string 'The abbreviation of "readonly"' 132 | COMPGEN consistency string 'The consistency requirements for the mount' 133 | COMPGEN bind-propagation string 'Refers to whether or not mounts created within a given bind mount or named volume can be propagated to replicas of that mount' 134 | COMPGEN bind-nonrecursive string 'To disable recursive bind-mount' 135 | } 136 | volume { 137 | COMPGEN source string 'The source of mount' 138 | COMPGEN src string 'The abbreviation of "source"' 139 | COMPGEN destination string 'The destination of mount' 140 | COMPGEN dst string 'The abbreviation of "destination"' 141 | COMPGEN target string 'The alias of "destination"' 142 | COMPGEN readonly string 'true or 1 or no value: readonly, false or 0: read-write' 143 | COMPGEN ro string 'The abbreviation of "readonly"' 144 | COMPGEN consistency string 'The consistency requirements for the mount' 145 | COMPGEN volume-driver string 'Name of the volume-driver plugin to use for the volume' 146 | COMPGEN volume-label string 'One or more custom metadata ("labels") to apply to the volume upon creation' 147 | COMPGEN volume-nocopy string 'To disable copying files from the container''s filesystem to the volume and mount the empty volume' 148 | COMPGEN volume-opt string 'Options specific to a given volume driver, which will be passed to the driver when creating the volume' 149 | } 150 | tmpfs { 151 | COMPGEN destination string 'The destination of mount' 152 | COMPGEN dst string 'The abbreviation of "destination"' 153 | COMPGEN target string 'The alias of "destination"' 154 | COMPGEN readonly string 'true or 1 or no value: readonly, false or 0: read-write' 155 | COMPGEN ro string 'The abbreviation of "readonly"' 156 | COMPGEN consistency string 'The consistency requirements for the mount' 157 | COMPGEN tmpfs-size string 'Size of the tmpfs mount in bytes' 158 | COMPGEN tmpfs-mode string 'File mode of the tmpfs in octal (e.g. "700" or "0700".)' 159 | } 160 | } 161 | return 162 | } 163 | 164 | $key = ($wordToComplete -split '=')[0] 165 | $values = switch ($key) { 166 | type { 'bind', 'volume', 'tmpfs' } 167 | { 'readonly', 'ro' -contains $_ } { 'true', 'false', 1, 0 } 168 | consistency {'default', 'consistent', 'cached', 'delegated'} 169 | bind-propagation { 'shared', 'slave', 'private', 'rshared', 'rslave', 'rprivate' } 170 | bind-nonrecursive { 'true', 'false' } 171 | volume-nocopy { 'true', 'false' } 172 | } 173 | 174 | foreach ($v in $values) { 175 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 176 | } 177 | } 178 | 179 | Register-Completer docker_--context $contextAll 180 | Register-Completer docker_-c (Get-Completer docker_--context) 181 | Register-Completer docker_--log-level { 'debug', 'info', 'warn', 'error', 'fatal' } 182 | Register-Completer docker_-l (Get-Completer docker_--log-level) 183 | 184 | Register-Completer docker_config_inspect $configAll 185 | Register-Completer docker_config_ls_--filter { 186 | Param([string]$wordToComplete) 187 | 188 | if ($wordToComplete -notlike '*=*') { 189 | COMPGEN id string 'Config ID' 190 | COMPGEN name string 'Config name' 191 | COMPGEN label string 'Config label' 192 | return 193 | } 194 | 195 | $key = ($wordToComplete -split '=')[0] 196 | $values = switch ($key) { 197 | id { docker config ls --quiet } 198 | name { docker config ls --format '{{.Name}}' } 199 | } 200 | 201 | foreach ($v in $values) { 202 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 203 | } 204 | } 205 | Register-Completer docker_config_rm $configAll 206 | 207 | Register-Completer docker_container_attach $containerRunning 208 | Register-Completer docker_container_commit { 209 | Param([string]$wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg) 210 | 211 | if ($indexOfFirstArg -lt 0) { 212 | Get-Container 213 | } else { 214 | $extent = $commandAst.CommandElements[$indexOfFirstArg].Extent 215 | if (($extent.StartOffset -le $cursorPosition) -and ($cursorPosition -le $extent.EndOffset)) { 216 | Get-Container 217 | } else { 218 | Get-Image 219 | } 220 | } 221 | } 222 | Register-Completer docker_container_create $imageAll 223 | Register-Completer docker_container_create_--cap-add $capAddable 224 | Register-Completer docker_container_create_--cap-drop $capDroppable 225 | Register-Completer docker_container_create_--cgroupns { 'host', 'private' } 226 | Register-Completer docker_container_create_--isolation $isolation 227 | Register-Completer docker_container_create_--log-driver $logDriver 228 | Register-Completer docker_container_create_--mount $mount 229 | Register-Completer docker_container_create_--platform $platform 230 | Register-Completer docker_container_create_--pull { 'always', 'missing', 'never' } 231 | Register-Completer docker_container_create_--volume $volumeAll 232 | Register-Completer docker_container_create_-v (Get-Completer docker_container_create_--volume) 233 | Register-Completer docker_container_create_--volumes-from $containerAll 234 | Register-Completer docker_container_diff $containerAll 235 | Register-Completer docker_container_exec $containerRunning 236 | Register-Completer docker_container_export $containerAll 237 | Register-Completer docker_container_inspect $containerAll 238 | Register-Completer docker_container_kill $containerRunning 239 | Register-Completer docker_container_logs $containerAll 240 | Register-Completer docker_container_ls_--filter { 241 | Param([string]$wordToComplete) 242 | 243 | if ($wordToComplete -notlike '*=*') { 244 | COMPGEN ancestor string 'Filter containers which share a given image as an ancestor' 245 | COMPGEN before string 'Filter containers created before a given container ID or name' 246 | COMPGEN exited string 'Represent the container''s exit code. Only useful with --all' 247 | COMPGEN expose string 'Filter containers which expose a given port' 248 | COMPGEN health string 'Filter containers based on their healthcheck status' 249 | COMPGEN id string 'Container''s ID' 250 | COMPGEN isolation string 'Windows daemon only' 251 | COMPGEN is-task boolean 'Filter containers that are a "task" for a service' 252 | COMPGEN label string 'An arbitrary string representing either a key or a key-value pair' 253 | COMPGEN name string 'Container''s name' 254 | COMPGEN network string 'Filter running containers connected to a given network' 255 | COMPGEN publish string 'Filter containers which publish a given port' 256 | COMPGEN since string 'Filter containers created after a given container ID or name' 257 | COMPGEN status string 'Container''s status' 258 | COMPGEN volume string 'Filter running containers which have mounted a given volume or bind mount' 259 | return 260 | } 261 | 262 | $key = ($wordToComplete -split '=')[0] 263 | $values = switch ($key) { 264 | ancestor { Get-Image } 265 | { 'before', 'since', 'name' -contains $_ } { 266 | Get-Container 267 | } 268 | health { 'starting', 'healthy', 'unhealthy', 'none' } 269 | id { docker container ls --format '{{.ID}}' --all } 270 | isolation { 'default', 'process', 'hyperv' } 271 | is-task { 'true', 'false' } 272 | network { Get-Network } 273 | status { 274 | 'created' 275 | 'dead' 276 | 'exited' 277 | 'paused' 278 | 'removing' 279 | 'restarting' 280 | 'running' 281 | } 282 | volume { Get-Volume } 283 | } 284 | 285 | foreach ($v in $values) { 286 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 287 | } 288 | } 289 | Register-Completer docker_container_ls_-f (Get-Completer docker_container_ls_--filter) 290 | Register-Completer docker_container_ls_--format $formatBasic 291 | Register-Completer docker_container_pause $containerRunning 292 | Register-Completer docker_container_port $containerAll 293 | Register-Completer docker_container_rename $containerAll 294 | Register-Completer docker_container_restart $containerAll 295 | Register-Completer docker_container_rm { 296 | Param($wordToComplete, $commandAst, $cursorPosition) 297 | 298 | $force = $false 299 | foreach ($ce in $commandAst.CommandElements) { 300 | if (@('--force', '-f') -contains $ce.Extent.Text) { 301 | $force = $true 302 | break 303 | } 304 | } 305 | 306 | if ($force) { 307 | Get-Container 308 | } else { 309 | Get-Container -Status created, exited 310 | } 311 | } 312 | Register-Completer docker_container_run $imageAll 313 | Register-Completer docker_container_run_--cap-add $capAddable 314 | Register-Completer docker_container_run_--cap-drop $capDroppable 315 | Register-Completer docker_container_run_--cgroupns { 'host', 'private' } 316 | Register-Completer docker_container_run_--isolation $isolation 317 | Register-Completer docker_container_run_--log-driver $logDriver 318 | Register-Completer docker_container_run_--network { 319 | Param([string]$wordToComplete) 320 | 321 | if ($wordToComplete -notlike 'container:*') { 322 | @( 323 | (docker system info --format '{{json .Plugins.Network}}' | ConvertFrom-Json) 324 | 'container' 325 | Get-Network 326 | ) | Sort-Object -Unique 327 | return 328 | } 329 | 330 | $values = Get-Container 331 | 332 | foreach ($v in $values) { 333 | COMPGEN "container:$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 334 | } 335 | } 336 | Register-Completer docker_container_run_--platform $platform 337 | Register-Completer docker_container_run_--pull { 'always', 'missing', 'never' } 338 | Register-Completer docker_container_start { Get-Container -Status created, exited } 339 | Register-Completer docker_container_run_--mount $mount 340 | Register-Completer docker_container_run_--volume $volumeAll 341 | Register-Completer docker_container_run_-v (Get-Completer docker_container_run_--volume) 342 | Register-Completer docker_container_run_--volumes-from $containerAll 343 | Register-Completer docker_container_stats $containerRunning 344 | Register-Completer docker_container_stop $containerRunning 345 | Register-Completer docker_container_top $containerRunning 346 | Register-Completer docker_container_wait $containerAll 347 | 348 | Register-Completer docker_context_create_--from $contextAll 349 | Register-Completer docker_context_export { 350 | Param([string]$wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg) 351 | 352 | if ($indexOfFirstArg -lt 0) { 353 | Get-Context 354 | } 355 | } 356 | Register-Completer docker_context_inspect $contextAll 357 | Register-Completer docker_context_rm $contextAll 358 | Register-Completer docker_context_update $contextAll 359 | Register-Completer docker_context_update_--default-stack-orchestrator { 'all', 'kubernetes', 'swarm' } 360 | Register-Completer docker_context_use $contextAll 361 | 362 | Register-Completer docker_image_build_--cache-from $imageAll 363 | Register-Completer docker_image_build_--isolation $isolation 364 | Register-Completer docker_image_build_--platform $platform 365 | Register-Completer docker_image_build_--progress { 'auto', 'plain', 'tty' } 366 | Register-Completer docker_image_build_--network { 367 | Param([string]$wordToComplete) 368 | 369 | if ($wordToComplete -notlike 'container:*') { 370 | @( 371 | (docker system info --format '{{json .Plugins.Network}}' | ConvertFrom-Json) 372 | 'container' 373 | Get-Network 374 | ) | Sort-Object -Unique 375 | return 376 | } 377 | 378 | $values = Get-Container 379 | 380 | foreach ($v in $values) { 381 | COMPGEN "container:$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 382 | } 383 | } 384 | Register-Completer docker_image_build_--secret { 385 | param ([string]$wordToComplete) 386 | 387 | if ($wordToComplete -notlike '*=*') { 388 | COMPGEN id string 'Secret name' 389 | COMPGEN source string 'Secret source' 390 | COMPGEN src string 'Abbreviation of "source"' 391 | COMPGEN type string 'Secret type' 392 | return 393 | } 394 | 395 | $key = ($wordToComplete -split '=')[0] 396 | $values = switch ($key) { 397 | id { Get-Secret } 398 | type { 'file' } 399 | } 400 | 401 | foreach ($v in $values) { 402 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 403 | } 404 | } 405 | Register-Completer docker_image_build_--tag $imageAll 406 | Register-Completer docker_image_build_-t (Get-Completer docker_image_build_--tag) 407 | Register-Completer docker_image_history $imageAll 408 | Register-Completer docker_image_history_--format { 409 | "'{{.Comment}}'" 410 | "'{{.CreatedAt}}'" 411 | "'{{.CreatedBy}}'" 412 | "'{{.CreatedSince}}'" 413 | "'{{.ID}}'" 414 | "'{{.Size}}'" 415 | } 416 | Register-Completer docker_image_history_--platform $platform 417 | Register-Completer docker_image_import { 418 | Param([string]$wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg) 419 | 420 | if ($indexOfFirstArg -ge 0) { 421 | if ($commandAst.CommandElements[$indexOfFirstArg].Extent.EndOffset -lt $cursorPosition) { 422 | # 2nd arg 423 | Get-Image 424 | } 425 | } 426 | } 427 | Register-Completer docker_image_import_--platform $platform 428 | Register-Completer docker_image_inspect $imageAll 429 | Register-Completer docker_image_inspect_--platform $platform 430 | Register-Completer docker_image_load_--platform $platform 431 | Register-Completer docker_image_ls $imageAll 432 | Register-Completer docker_image_ls_--filter { 433 | Param([string]$wordToComplete) 434 | 435 | if ($wordToComplete -notlike '*=*') { 436 | COMPGEN before string 'Filter images created before a given container ID or name' 437 | COMPGEN dangling string 'Show untagged images' 438 | COMPGEN label string 'An arbitrary string representing either a key or a key-value pair' 439 | COMPGEN reference string 'Filter images whose reference matches the specified pattern' 440 | COMPGEN since string 'Filter images created after a given container ID or name' 441 | return 442 | } 443 | 444 | $key = ($wordToComplete -split '=')[0] 445 | $values = switch ($key) { 446 | { 'before', 'since', 'reference' -contains $_ } { 447 | Get-Image 448 | } 449 | dangling { 'true', 'false' } 450 | } 451 | 452 | foreach ($v in $values) { 453 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 454 | } 455 | } 456 | Register-Completer docker_image_ls_-f (Get-Completer docker_image_ls_--filter) 457 | Register-Completer docker_image_ls_--format $formatBasic 458 | Register-Completer docker_image_pull $imageAll 459 | Register-Completer docker_image_pull_--all-tags { Get-ImageRepository } 460 | Register-Completer docker_image_pull_-a { Get-ImageRepository } 461 | Register-Completer docker_image_pull_--platform $platform 462 | Register-Completer docker_image_push $imageAll 463 | Register-Completer docker_image_push_--platform $platform 464 | Register-Completer docker_image_rm $imageAll 465 | Register-Completer docker_image_save $imageAll 466 | Register-Completer docker_image_save_--platform $platform 467 | Register-Completer docker_image_tag $imageAll 468 | 469 | Register-Completer docker_network_connect { 470 | Param([string]$wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg) 471 | 472 | if ($indexOfFirstArg -lt 0) { 473 | Get-Network 474 | } else { 475 | $extent = $commandAst.CommandElements[$indexOfFirstArg].Extent 476 | if (($extent.StartOffset -le $cursorPosition) -and ($cursorPosition -le $extent.EndOffset)) { 477 | Get-Network 478 | } else { 479 | Get-Container 480 | } 481 | } 482 | } 483 | Register-Completer docker_network_create_--driver { 484 | (docker system info --format '{{json .Plugins.Network}}' | ConvertFrom-Json) | 485 | Where-Object { $_ -notin @('host', 'null') } 486 | } 487 | Register-Completer docker_network_create_-d (Get-Completer docker_network_create_--driver) 488 | Register-Completer docker_network_disconnect { 489 | Param([string]$wordToComplete, $commandAst, $cursorPosition, $indexOfFirstArg) 490 | 491 | if ($indexOfFirstArg -lt 0) { 492 | Get-Network 493 | } else { 494 | $extent = $commandAst.CommandElements[$indexOfFirstArg].Extent 495 | if (($extent.StartOffset -le $cursorPosition) -and ($cursorPosition -le $extent.EndOffset)) { 496 | Get-Network 497 | } else { 498 | $containersInNetwork = docker network inspect --format '{{json .Containers}}' $extent.Text 499 | ($containersInNetwork | ConvertFrom-Json).psobject.Properties.Value.Name | Sort-Object 500 | } 501 | } 502 | } 503 | Register-Completer docker_network_inspect $networkAll 504 | Register-Completer docker_network_ls_--filter { 505 | Param([string]$wordToComplete) 506 | 507 | if ($wordToComplete -notlike '*=*') { 508 | COMPGEN driver string 'Network driver' 509 | COMPGEN id string 'Network id' 510 | COMPGEN label string ' or =' 511 | COMPGEN name string 'Network name' 512 | COMPGEN scope string 'Scope name' 513 | COMPGEN type string 'Type name' 514 | return 515 | } 516 | 517 | $key = ($wordToComplete -split '=')[0] 518 | $values = switch ($key) { 519 | driver { docker system info --format '{{json .Plugins.Network}}' | ConvertFrom-Json } 520 | id { docker network ls --format '{{.ID}}' } 521 | name { docker network ls --format '{{.Name}}' } 522 | scope { 'global', 'local', 'swarm' } 523 | type { 'builtin', 'custom' } 524 | } 525 | 526 | foreach ($v in $values) { 527 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 528 | } 529 | } 530 | Register-Completer docker_network_ls_-f (Get-Completer docker_network_ls_--filter) 531 | Register-Completer docker_network_rm { Get-Network -Type custom } 532 | 533 | Register-Completer docker_node_demote { Get-Node -Role manager } 534 | Register-Completer docker_node_inspect { 535 | Get-Node 536 | 'self' 537 | } 538 | Register-Completer docker_node_ls_--filter { 539 | Param([string]$wordToComplete) 540 | 541 | if ($wordToComplete -notlike '*=*') { 542 | COMPGEN id string 'Node id' 543 | COMPGEN label string ' or =' 544 | COMPGEN membership string 'accepted or pending' 545 | COMPGEN name string 'Node hostname' 546 | COMPGEN role string 'manager or worker' 547 | return 548 | } 549 | 550 | $key = ($wordToComplete -split '=')[0] 551 | $values = switch ($key) { 552 | id { docker node ls --quiet } 553 | membership { 'accepted', 'pending' } 554 | name { docker node ls --format '{{.Hostname}}' } 555 | role { 'manager', 'worker' } 556 | } 557 | 558 | foreach ($v in $values) { 559 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 560 | } 561 | } 562 | Register-Completer docker_node_ls_-f (Get-Completer docker_node_ls_--filter) 563 | Register-Completer docker_node_ls_--format { 564 | "'{{.Availability}}'" 565 | "'{{.Hostname}}'" 566 | "'{{.ID}}'" 567 | "'{{.ManagerStatus}}'" 568 | "'{{.Self}}'" 569 | "'{{.Status}}'" 570 | "'{{.TLSStatus}}'" 571 | } 572 | Register-Completer docker_node_promote { Get-Node -Role worker } 573 | Register-Completer docker_node_ps { 574 | Get-Node 575 | 'self' 576 | } 577 | Register-Completer docker_node_ps_--filter { 578 | Param([string]$wordToComplete) 579 | 580 | if ($wordToComplete -notlike '*=*') { 581 | COMPGEN desired-state string 'Desired state of the task' 582 | COMPGEN id string 'Task id' 583 | COMPGEN label string ' or =' 584 | COMPGEN name string 'Task name' 585 | return 586 | } 587 | 588 | $key = ($wordToComplete -split '=')[0] 589 | $values = switch ($key) { 590 | desired-state { 'accepted', 'running', 'shutdown' } 591 | id { docker node ps --quiet } 592 | name { docker node ps --format '{{.Name}}' } 593 | } 594 | 595 | foreach ($v in $values) { 596 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 597 | } 598 | } 599 | Register-Completer docker_node_ps_-f (Get-Completer docker_node_ps_--filter) 600 | Register-Completer docker_node_ps_--format { 601 | "'{{.CurrentState}}'" 602 | "'{{.DesiredState}}'" 603 | "'{{.Error}}'" 604 | "'{{.Image}}'" 605 | "'{{.Name}}'" 606 | "'{{.Node}}'" 607 | "'{{.Ports}}'" 608 | } 609 | Register-Completer docker_node_rm { Get-Node } 610 | Register-Completer docker_node_update { Get-Node } 611 | Register-Completer docker_node_update_--availability { 'active', 'drain', 'pause' } 612 | Register-Completer docker_node_update_--role { 'manager', 'worker' } 613 | 614 | Register-Completer docker_plugin_ls_--filter { 615 | Param([string]$wordToComplete) 616 | 617 | if ($wordToComplete -notlike '*=*') { 618 | COMPGEN capability string 'Plugin capabilities' 619 | COMPGEN enabled boolean 'True or false' 620 | return 621 | } 622 | 623 | $key = ($wordToComplete -split '=')[0] 624 | $values = switch ($key) { 625 | capability { 'authz', 'ipamdriver', 'logdriver', 'metricscollector', 'networkdriver', 'volumedriver' } 626 | enabled { 'true', 'false' } 627 | } 628 | 629 | foreach ($v in $values) { 630 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 631 | } 632 | } 633 | Register-Completer docker_plugin_ls_-f (Get-Completer docker_plugin_ls_--filter) 634 | 635 | Register-Completer docker_secret_inspect { Get-Secret } 636 | Register-Completer docker_secret_ls_--filter { 637 | Param([string]$wordToComplete) 638 | 639 | if ($wordToComplete -notlike '*=*') { 640 | COMPGEN id string 'Secret id' 641 | COMPGEN label string ' or =' 642 | COMPGEN name string 'Secret name' 643 | return 644 | } 645 | 646 | $key = ($wordToComplete -split '=')[0] 647 | $values = switch ($key) { 648 | id { docker secret ls --quiet } 649 | name { docker secret ls --format '{{.Name}}' } 650 | } 651 | 652 | foreach ($v in $values) { 653 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 654 | } 655 | } 656 | Register-Completer docker_secret_ls_-f (Get-Completer docker_secret_ls_--filter) 657 | Register-Completer docker_secret_ls_--format { 658 | "'{{.CreatedAt}}'" 659 | "'{{.ID}}'" 660 | "'{{.Labels}}'" 661 | "'{{.Name}}'" 662 | "'{{.UpdatedAt}}'" 663 | } 664 | Register-Completer docker_secret_rm { Get-Secret } 665 | 666 | Register-Completer docker_search_--filter { 667 | Param([string]$wordToComplete) 668 | 669 | if ($wordToComplete -notlike '*=*') { 670 | COMPGEN is-automated boolean 'Autobuild or not' 671 | COMPGEN is-official boolean 'Official repository or not' 672 | COMPGEN stars int 'Number of stars' 673 | return 674 | } 675 | 676 | $key = ($wordToComplete -split '=')[0] 677 | $values = switch ($key) { 678 | is-automated { 'true', 'false' } 679 | is-official { 'true', 'false' } 680 | } 681 | 682 | foreach ($v in $values) { 683 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 684 | } 685 | } 686 | 687 | Register-Completer docker_service_create $imageAll 688 | Register-Completer docker_service_create_--cap-add $capAddable 689 | Register-Completer docker_service_create_--cap-drop $capDroppable 690 | Register-Completer docker_service_create_--config $configAll 691 | Register-Completer docker_service_create_--endpoint-mode { 'dnsrr', 'vip' } 692 | Register-Completer docker_service_create_--isolation $isolation 693 | Register-Completer docker_service_create_--log-driver $logDriver 694 | Register-Completer docker_service_create_--mode { 'global', 'global-job', 'replicated', 'replicated-job' } 695 | Register-Completer docker_service_create_--mount $mount 696 | Register-Completer docker_service_create_--restart-condition { 'any', 'none', 'on-failure' } 697 | Register-Completer docker_service_create_--rollback-failure-action { 'continue', 'pause' } 698 | Register-Completer docker_service_create_--rollback-order { 'start-first', 'stop-first' } 699 | Register-Completer docker_service_create_--secret { Get-Secret } 700 | Register-Completer docker_service_create_--update-failure-action { 'continue', 'pause', 'rollback' } 701 | Register-Completer docker_service_create_--update-order { 'start-first', 'stop-first' } 702 | Register-Completer docker_service_inspect $serviceAll 703 | Register-Completer docker_service_logs { 704 | $services = Get-Service 705 | $services 706 | foreach ($s in $services) { 707 | docker service ps --format '{{.ID}}' $s 708 | } 709 | } 710 | Register-Completer docker_service_ls_--filter { 711 | Param([string]$wordToComplete) 712 | 713 | if ($wordToComplete -notlike '*=*') { 714 | COMPGEN id string 'Service id' 715 | COMPGEN label string ' or =' 716 | COMPGEN mode string 'Service mode' 717 | COMPGEN name string 'Service name' 718 | return 719 | } 720 | 721 | $key = ($wordToComplete -split '=')[0] 722 | $values = switch ($key) { 723 | id { docker service ls --quiet } 724 | mode { 'global', 'replicated' } 725 | name { docker service ls --format '{{.Name}}' } 726 | } 727 | 728 | foreach ($v in $values) { 729 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 730 | } 731 | } 732 | Register-Completer docker_service_ps $serviceAll 733 | Register-Completer docker_service_ps_--filter { 734 | Param([string]$wordToComplete) 735 | 736 | if ($wordToComplete -notlike '*=*') { 737 | COMPGEN desired-state string 'Desired state of the task' 738 | COMPGEN id string 'Task id' 739 | COMPGEN name string 'Task name' 740 | COMPGEN node string 'Node name or id' 741 | return 742 | } 743 | 744 | $key = ($wordToComplete -split '=')[0] 745 | $values = switch ($key) { 746 | desired-state { 'accepted', 'running', 'shutdown' } 747 | id { docker node ps --quiet } 748 | name { docker node ps --format '{{.Name}}' } 749 | node { 750 | Get-Node 751 | 'self' 752 | } 753 | } 754 | 755 | foreach ($v in $values) { 756 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 757 | } 758 | } 759 | Register-Completer docker_service_ps_-f (Get-Completer docker_service_ps_--filter) 760 | Register-Completer docker_service_rm $serviceAll 761 | Register-Completer docker_service_scale { 762 | docker service ls --format '{{.Name}}' | ForEach-Object { 763 | COMPGEN "$_=" string $_ $_ ([System.Management.Automation.CompletionResultType]::ParameterValue) 764 | } 765 | } 766 | Register-Completer docker_service_update $serviceAll 767 | Register-Completer docker_service_update_--cap-add $capAddable 768 | Register-Completer docker_service_update_--cap-drop $capDroppable 769 | Register-Completer docker_service_update_--config-add $configAll 770 | Register-Completer docker_service_update_--config-rm $configAll 771 | Register-Completer docker_service_update_--endpoint-mode { 'dnsrr', 'vip' } 772 | Register-Completer docker_service_update_--image $imageAll 773 | Register-Completer docker_service_update_--isolation $isolation 774 | Register-Completer docker_service_update_--log-driver (Get-Completer docker_service_create_--log-driver) 775 | Register-Completer docker_service_update_--mount-add $mount 776 | Register-Completer docker_service_update_--network-add $networkAll 777 | Register-Completer docker_service_update_--network-rm $networkAll 778 | Register-Completer docker_service_update_--restart-condition (Get-Completer docker_service_create_--restart-condition) 779 | Register-Completer docker_service_update_--rollback-failure-action (Get-Completer docker_service_create_--rollback-failure-action) 780 | Register-Completer docker_service_update_--rollback-order (Get-Completer docker_service_create_--rollback-order) 781 | Register-Completer docker_service_update_--secret-add { Get-Secret } 782 | Register-Completer docker_service_update_--secret-rm { Get-Secret } 783 | Register-Completer docker_service_update_--update-failure-action (Get-Completer docker_service_create_--update-failure-action) 784 | Register-Completer docker_service_update_--update-order (Get-Completer docker_service_create_--update-order) 785 | 786 | Register-Completer docker_stack_--orchestrator { 'swarm', 'kubernetes', 'all' } 787 | Register-Completer docker_stack_deploy $stackAll 788 | Register-Completer docker_stack_deploy_--resolve-image { 'always', 'changed', 'never' } 789 | Register-Completer docker_stack_ps $stackAll 790 | Register-Completer docker_stack_ps_--filter { 791 | Param([string]$wordToComplete) 792 | 793 | if ($wordToComplete -notlike '*=*') { 794 | COMPGEN desired-state string 'Desired state of the task' 795 | COMPGEN id string 'Task id' 796 | COMPGEN name string 'Task name' 797 | COMPGEN node string 'Node name or id' 798 | return 799 | } 800 | 801 | $key = ($wordToComplete -split '=')[0] 802 | $values = switch ($key) { 803 | desired-state { 'accepted', 'running', 'shutdown' } 804 | id { docker node ps --quiet } 805 | name { docker node ps --format '{{.Name}}' } 806 | node { Get-Node } 807 | } 808 | 809 | foreach ($v in $values) { 810 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 811 | } 812 | } 813 | Register-Completer docker_stack_ps_-f (Get-Completer docker_stack_ps_--filter) 814 | Register-Completer docker_stack_rm $stackAll 815 | Register-Completer docker_stack_services $stackAll 816 | Register-Completer docker_stack_services_--filter { 817 | Param([string]$wordToComplete) 818 | 819 | if ($wordToComplete -notlike '*=*') { 820 | COMPGEN id string 'Service id' 821 | COMPGEN label string ' or =' 822 | COMPGEN name string 'Service name' 823 | return 824 | } 825 | 826 | $key = ($wordToComplete -split '=')[0] 827 | $values = switch ($key) { 828 | id { docker service ls --quiet } 829 | name { docker service ls --format '{{.Name}}' } 830 | } 831 | 832 | foreach ($v in $values) { 833 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 834 | } 835 | } 836 | Register-Completer docker_stack_services_-f (Get-Completer docker_stack_services_--filter) 837 | 838 | Register-Completer docker_swarm_init_--availability { 'active', 'drain', 'pause' } 839 | Register-Completer docker_swarm_join_--availability { 'active', 'drain', 'pause' } 840 | Register-Completer docker_swarm_join-token { 'manager', 'worker' } 841 | 842 | Register-Completer docker_system_df_--format $formatBasic 843 | Register-Completer docker_system_events_--filter { 844 | Param([string]$wordToComplete) 845 | 846 | if ($wordToComplete -notlike '*=*') { 847 | COMPGEN config string 'Config name or id' 848 | COMPGEN container string 'Container name or id' 849 | COMPGEN daemon string 'Daemon name or id' 850 | COMPGEN event string 'Event name' 851 | COMPGEN image string 'Image name or id' 852 | COMPGEN label string ' or =' 853 | COMPGEN network string 'Network name or id' 854 | COMPGEN node string 'Node id' 855 | COMPGEN plugin string 'Plugin name or id' 856 | COMPGEN scope string 'local or swarm' 857 | COMPGEN secret string 'Secret name or id' 858 | COMPGEN service string 'Service name or id' 859 | COMPGEN type string 'Object type' 860 | COMPGEN volume string 'Volume name or id' 861 | return 862 | } 863 | 864 | $key = ($wordToComplete -split '=')[0] 865 | $values = switch ($key) { 866 | config { Get-Config } 867 | container { Get-Container } 868 | daemon { 869 | docker system info --format '{{.Name}}' 870 | docker system info --format '{{.ID}}' 871 | } 872 | event { 873 | 'attach' 874 | 'commit' 875 | 'connect' 876 | 'copy' 877 | 'create' 878 | 'delete' 879 | 'destroy' 880 | 'detach' 881 | 'die' 882 | 'disable' 883 | 'disconnect' 884 | 'enable' 885 | 'exec_create' 886 | 'exec_detach' 887 | 'exec_start' 888 | 'export' 889 | 'health_status' 890 | 'import' 891 | 'install' 892 | 'kill' 893 | 'load' 894 | 'mount' 895 | 'oom' 896 | 'pause' 897 | 'pull' 898 | 'push' 899 | 'reload' 900 | 'remove' 901 | 'rename' 902 | 'resize' 903 | 'restart' 904 | 'save' 905 | 'start' 906 | 'stop' 907 | 'tag' 908 | 'top' 909 | 'unmount' 910 | 'unpause' 911 | 'untag' 912 | 'update' 913 | } 914 | image { Get-Image } 915 | network { Get-Network } 916 | node { docker node ls --quiet } 917 | plugin { Get-Plugin } 918 | scope { 'local', 'swarm' } 919 | secret { Get-Secret } 920 | service { Get-Service } 921 | type { 'config', 'container', 'daemon', 'image', 'network', 'node', 'plugin', 'secret', 'service', 'volume' } 922 | volume { Get-Volume } 923 | } 924 | 925 | foreach ($v in $values) { 926 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 927 | } 928 | } 929 | Register-Completer docker_system_events_-f (Get-Completer docker_system_events_--filter) 930 | Register-Completer docker_system_events_--format $formatBasic 931 | Register-Completer docker_system_info_--format $formatBasic 932 | 933 | Register-Completer docker_trust_inspect $imageAll 934 | Register-Completer docker_trust_revoke $imageAll 935 | Register-Completer docker_trust_sign { Get-Image -WithTag } 936 | 937 | Register-Completer docker_volume_create_--availability { 'active', 'drain', 'pause' } 938 | Register-Completer docker_volume_create_--scope { 'multi', 'single' } 939 | Register-Completer docker_volume_create_--sharing { 'all', 'none', 'onewriter', 'readonly' } 940 | Register-Completer docker_volume_create_--type { 'block', 'mount' } 941 | Register-Completer docker_volume_inspect $volumeAll 942 | Register-Completer docker_volume_ls_--filter { 943 | Param([string]$wordToComplete) 944 | 945 | if ($wordToComplete -notlike '*=*') { 946 | COMPGEN dangling string 'Referenced or not' 947 | COMPGEN driver string 'Volume''s driver name' 948 | COMPGEN label string ' or =' 949 | COMPGEN name string 'Volume''s name' 950 | return 951 | } 952 | 953 | $key = ($wordToComplete -split '=')[0] 954 | $values = switch ($key) { 955 | dangling { 'true', 'false' } 956 | driver { docker system info --format '{{json .Plugins.Volume}}' | ConvertFrom-Json } 957 | name { Get-Volume } 958 | } 959 | 960 | foreach ($v in $values) { 961 | COMPGEN "$key=$v" string $v $v ([System.Management.Automation.CompletionResultType]::ParameterValue) 962 | } 963 | } 964 | Register-Completer docker_volume_ls_-f (Get-Completer docker_volume_ls_--filter) 965 | Register-Completer docker_volume_ls_--format { 966 | "'{{.Driver}}'" 967 | "'{{.Label}}'" 968 | "'{{.Labels}}'" 969 | "'{{.Mountpoint}}'" 970 | "'{{.Name}}'" 971 | "'{{.Scope}}'" 972 | } 973 | 974 | Register-Completer docker_volume_rm $volumeAll 975 | Register-Completer docker_volume_update $volumeCluster 976 | Register-Completer docker_volume_update_--availability { 'active', 'drain', 'pause' } 977 | 978 | Register-Completer docker_builder_build_--cache-from (Get-Completer docker_image_build_--cache-from) 979 | Register-Completer docker_builder_build_--isolation (Get-Completer docker_image_build_--isolation) 980 | Register-Completer docker_builder_build_--platform $platform 981 | Register-Completer docker_builder_build_--progress (Get-Completer docker_image_build_--progress) 982 | Register-Completer docker_builder_build_--network (Get-Completer docker_image_build_--network) 983 | Register-Completer docker_builder_build_--secret (Get-Completer docker_image_build_--secret) 984 | Register-Completer docker_builder_build_--tag (Get-Completer docker_image_build_--tag) 985 | Register-Completer docker_builder_build_-t (Get-Completer docker_image_build_-t) 986 | 987 | Register-Completer docker_build_--cache-from (Get-Completer docker_image_build_--cache-from) 988 | Register-Completer docker_build_--isolation (Get-Completer docker_image_build_--isolation) 989 | Register-Completer docker_build_--platform (Get-Completer docker_image_build_--platform) 990 | Register-Completer docker_build_--progress (Get-Completer docker_image_build_--progress) 991 | Register-Completer docker_build_--network (Get-Completer docker_image_build_--network) 992 | Register-Completer docker_build_--secret (Get-Completer docker_image_build_--secret) 993 | Register-Completer docker_build_--tag (Get-Completer docker_image_build_--tag) 994 | Register-Completer docker_build_-t (Get-Completer docker_build_--tag) 995 | 996 | Register-Completer docker_run (Get-Completer docker_container_run) 997 | Register-Completer docker_run_--cap-add (Get-Completer docker_container_run_--cap-add) 998 | Register-Completer docker_run_--cap-drop (Get-Completer docker_container_run_--cap-drop) 999 | Register-Completer docker_run_--cgroupns (Get-Completer docker_container_run_--cgroupns) 1000 | Register-Completer docker_run_--isolation (Get-Completer docker_container_run_--isolation) 1001 | Register-Completer docker_run_--mount (Get-Completer docker_container_run_--mount) 1002 | Register-Completer docker_run_--network (Get-Completer docker_container_run_--network) 1003 | Register-Completer docker_run_--log-driver (Get-Completer docker_container_run_--log-driver) 1004 | Register-Completer docker_run_--platform (Get-Completer docker_container_run_--platform) 1005 | Register-Completer docker_run_--pull (Get-Completer docker_container_run_--pull) 1006 | Register-Completer docker_run_--volume (Get-Completer docker_container_run_--volume) 1007 | Register-Completer docker_run_-v (Get-Completer docker_run_--volume) 1008 | Register-Completer docker_run_--volumes-from (Get-Completer docker_container_run_--volumes-from) 1009 | 1010 | if ($env:DOCKER_HIDE_LEGACY_COMMANDS) { 1011 | return 1012 | } 1013 | 1014 | Register-Completer docker_attach (Get-Completer docker_container_attach) 1015 | Register-Completer docker_commit (Get-Completer docker_container_commit) 1016 | Register-Completer docker_create (Get-Completer docker_container_create) 1017 | Register-Completer docker_create_--cap-add (Get-Completer docker_container_create_--cap-add) 1018 | Register-Completer docker_create_--cap-drop (Get-Completer docker_container_create_--cap-drop) 1019 | Register-Completer docker_create_--cgroupns (Get-Completer docker_container_create_--cgroupns) 1020 | Register-Completer docker_create_--isolation (Get-Completer docker_container_create_--isolation) 1021 | Register-Completer docker_create_--log-driver (Get-Completer docker_container_create_--log-driver) 1022 | Register-Completer docker_create_--mount (Get-Completer docker_container_create_--mount) 1023 | Register-Completer docker_create_--platform (Get-Completer docker_container_create_--platform) 1024 | Register-Completer docker_create_--pull (Get-Completer docker_container_create_--pull) 1025 | Register-Completer docker_create_--volume (Get-Completer docker_container_create_--volume) 1026 | Register-Completer docker_create_-v (Get-Completer docker_create_--volume) 1027 | Register-Completer docker_create_--volumes-from (Get-Completer docker_container_create_--volumes-from) 1028 | Register-Completer docker_diff (Get-Completer docker_container_diff) 1029 | Register-Completer docker_events_--filter (Get-Completer docker_system_events_--filter) 1030 | Register-Completer docker_events_-f (Get-Completer docker_events_--filter) 1031 | Register-Completer docker_events_--format (Get-Completer docker_system_events_--format) 1032 | Register-Completer docker_exec (Get-Completer docker_container_exec) 1033 | Register-Completer docker_export (Get-Completer docker_container_export) 1034 | Register-Completer docker_history (Get-Completer docker_image_history) 1035 | Register-Completer docker_history_--format (Get-Completer docker_image_history_--format) 1036 | Register-Completer docker_history_--platform (Get-Completer docker_image_history_--platform) 1037 | Register-Completer docker_images (Get-Completer docker_image_ls) 1038 | Register-Completer docker_import (Get-Completer docker_image_import) 1039 | Register-Completer docker_import_--platform (Get-Completer docker_image_import_--platform) 1040 | Register-Completer docker_images_--filter (Get-Completer docker_image_ls_--filter) 1041 | Register-Completer docker_images_-f (Get-Completer docker_images_--filter) 1042 | Register-Completer docker_images_--format (Get-Completer docker_image_ls_--format) 1043 | Register-Completer docker_info_--format (Get-Completer docker_system_info_--format) 1044 | Register-Completer docker_inspect { 1045 | Param($wordToComplete, $commandAst, $cursorPosition) 1046 | 1047 | $type = $null 1048 | for ($i = 2; $i -lt $commandAst.CommandElements.Count; $i++) { 1049 | $ce = $commandAst.CommandElements[$i] 1050 | if ('--type' -eq $ce.Extent.Text) { 1051 | $type = $commandAst.CommandElements[$i + 1].Extent.Text 1052 | break 1053 | } 1054 | } 1055 | 1056 | switch ($type) { 1057 | '' { 1058 | Get-Container 1059 | Get-Image 1060 | Get-Network 1061 | Get-Node 1062 | Get-Plugin 1063 | Get-Secret 1064 | Get-Service 1065 | Get-Volume 1066 | } 1067 | container { Get-Container } 1068 | image { Get-Image } 1069 | network { Get-Network } 1070 | node { Get-Node } 1071 | plugin { Get-Plugin } 1072 | secret { Get-Secret } 1073 | service { Get-Service } 1074 | volume { Get-Volume } 1075 | } 1076 | } 1077 | Register-Completer docker_inspect_--type { 'container', 'image', 'network', 'node', 'plugin', 'secret', 'service', 'volume' } 1078 | Register-Completer docker_kill (Get-Completer docker_container_kill) 1079 | Register-Completer docker_load_--platform (Get-Completer docker_image_load_--platform) 1080 | Register-Completer docker_logs (Get-Completer docker_container_logs) 1081 | Register-Completer docker_pause (Get-Completer docker_container_pause) 1082 | Register-Completer docker_port (Get-Completer docker_container_port) 1083 | Register-Completer docker_ps_--filter (Get-Completer docker_container_ls_--filter) 1084 | Register-Completer docker_ps_-f (Get-Completer docker_ps_--filter) 1085 | Register-Completer docker_ps_--format (Get-Completer docker_container_ls_--format) 1086 | Register-Completer docker_pull (Get-Completer docker_image_pull) 1087 | Register-Completer docker_pull_--all-tags (Get-Completer docker_image_pull_--all-tags) 1088 | Register-Completer docker_pull_-a (Get-Completer docker_pull_--all-tags) 1089 | Register-Completer docker_pull_--platform (Get-Completer docker_image_pull_--platform) 1090 | Register-Completer docker_push (Get-Completer docker_image_push) 1091 | Register-Completer docker_push_--platform (Get-Completer docker_image_push_--platform) 1092 | Register-Completer docker_rename (Get-Completer docker_container_rename) 1093 | Register-Completer docker_restart (Get-Completer docker_container_restart) 1094 | Register-Completer docker_rm (Get-Completer docker_container_rm) 1095 | Register-Completer docker_rmi (Get-Completer docker_image_rm) 1096 | Register-Completer docker_save (Get-Completer docker_image_save) 1097 | Register-Completer docker_save_--platform (Get-Completer docker_image_save_--platform) 1098 | Register-Completer docker_start (Get-Completer docker_container_start) 1099 | Register-Completer docker_stats (Get-Completer docker_container_stats) 1100 | Register-Completer docker_stop (Get-Completer docker_container_stop) 1101 | Register-Completer docker_tag (Get-Completer docker_image_tag) 1102 | Register-Completer docker_top (Get-Completer docker_container_top) 1103 | Register-Completer docker_wait (Get-Completer docker_container_wait) 1104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2025 Masatoshi Higuchi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DockerCompletion for PowerShell 2 | 3 | ![demo](demo.gif) 4 | 5 | * Many completions (probably much more than you imagine :smiley:) 6 | * Automatic detection of aliases [like `d`](#i-use-alias-d-for-docker-does-the-completion-work-for-the-alias) and others 7 | * Wild card (`*`) support 8 | * [Customizable](#customization) 9 | * Contributions welcome! 10 | 11 | ## Requirements 12 | * PowerShell >= 5.0 13 | * docker cli >= 1.13 in `$env:PATH` 14 | 15 | ### Optional 16 | * [Compose v2](https://github.com/docker/compose) 17 | 18 | It is used for `docker compose` completion. 19 | The supported version will be bumped up frequently. 20 | For information about it, see the comment of [Compose/completers.ps1](DockerCompletion/Compose/completers.ps1). 21 | 22 | ## Installation 23 | 24 | ```powershell 25 | # Install from PowerShell Gallery 26 | Install-Module DockerCompletion -Scope CurrentUser 27 | # Import 28 | Import-Module DockerCompletion 29 | ``` 30 | 31 | Don't forget to execute the `Import-Module` command every time you start a new PowerShell session. You can do it automatically [by using PowerShell profile](#how-can-i-execute-import-module-automatically). 32 | 33 | ### Other methods 34 | 35 |
36 | Git 37 | 38 | ```powershell 39 | # Shallow clone from GitHub 40 | git clone --depth 1 https://github.com/matt9ucci/DockerCompletion 41 | # Import 42 | Import-Module ./DockerCompletion/DockerCompletion 43 | ``` 44 | 45 |
46 | 47 |
48 | As a "well-formed" module 49 | 50 | DockerCompletion is a "well-formed" module. 51 | You can install and import it in the usual manner as follows. 52 | 53 | #### Install 54 | 55 | Download and place the [DockerCompletion directory and files](./DockerCompletion) in `$env:PSModulePath`. 56 | 57 | You can see the paths listed in `$env:PSModulePath` as follows: 58 | ```powershell 59 | PS C:\> $env:PSModulePath -split ';' 60 | C:\Users\matt9ucci\Documents\WindowsPowerShell\Modules 61 | C:\Program Files\WindowsPowerShell\Modules 62 | C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules 63 | ``` 64 | 65 | If your target path is `C:\Users\matt9ucci\Documents\WindowsPowerShell\Modules`, execute the following commands: 66 | 67 | ```powershell 68 | # Uninstall previous version 69 | Remove-Item $HOME\Documents\WindowsPowerShell\Modules\DockerCompletion\ -Recurse -Force 70 | # Download 71 | Invoke-WebRequest https://github.com/matt9ucci/DockerCompletion/archive/master.zip -OutFile master.zip 72 | # Unzip the downloaded archive 73 | Expand-Archive master.zip 74 | # Place the unzipped files and directory in $env:PSModulePath 75 | Move-Item master\DockerCompletion-master\DockerCompletion\ "$HOME\Documents\WindowsPowerShell\Modules\" 76 | # Clean up 77 | Remove-Item master.zip 78 | Remove-Item master -Recurse -Force 79 | ``` 80 | 81 | `$HOME` is a PowerShell's automatic variable containing the full path of the user's home directory (in this case `C:\Users\matt9ucci`). 82 | 83 | #### Import 84 | 85 | Execute the following command to check if you can import DockerCompletion: 86 | 87 | ```powershell 88 | PS C:\> Get-Module -ListAvailable DockerCompletion 89 | 90 | Directory: C:\Users\matt9ucci\Documents\WindowsPowerShell\Modules 91 | 92 | ModuleType Version Name ExportedCommands 93 | ---------- ------- ---- ---------------- 94 | Manifest 1.2010.... DockerCompletion 95 | ``` 96 | 97 | After the check, execute the following command to import the installed module: 98 | 99 | ```powershell 100 | Import-Module DockerCompletion 101 | ``` 102 | 103 |
104 | 105 | ## Customization 106 | 107 | You can add your own completers and modify default completers with your custom script. 108 | 109 | For information about how to write custom scripts, see [completers.ps1](DockerCompletion/completers.ps1) and [completers4arguments.ps1](DockerCompletion/completers4arguments.ps1) 110 | 111 | To apply your custom script, pass the path as `Import-Module`'s ArgumentList parameter: 112 | ```powershell 113 | Import-Module DockerCompletion -ArgumentList pathto\custom1.ps1, pathto\custom2.ps1 114 | ``` 115 | 116 | ## Known Issues 117 | In PowerShell 5.0/5.1, with one dash (`-`) and double dash (`--`), completers are not invoked because of [a PowerShell's bug](https://github.com/PowerShell/PowerShell/issues/2912). 118 | It will be [fixed in PowerShell 6.0](https://github.com/PowerShell/PowerShell/pull/3633). 119 | 120 | A workaround for this issue is to type a character following `-` and `--`. 121 | For example, type `--a` and press tab. 122 | 123 | ## FAQ 124 | 125 | ### How can I execute `Import-Module` automatically? 126 | 127 | Use [PowerShell profile](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles). 128 | For example, run the following commands: 129 | 130 | ```powershell 131 | # Create your profile 132 | New-Item $PROFILE -ItemType File -Force 133 | # Add the import command to the profile 134 | Add-Content $PROFILE 'Import-Module DockerCompletion' 135 | ``` 136 | 137 | Whenever you start a new PowerShell session, the commands in the `$PROFILE` are executed each time. 138 | 139 | ### I use alias `d` for `docker`. Does the completion work for the alias? 140 | 141 | Yes, it does. DockerCompletion detects aliases for `docker` when executing `Import-Module`. 142 | For example: 143 | 144 | ```powershell 145 | # Set the alias `d` for `docker` 146 | Set-Alias d docker 147 | # Detect the alias `d` and register completers for both `docker` and `d` 148 | Import-Module DockerCompletion 149 | ``` 150 | 151 | ## Misc 152 | 153 | This github repository will be often rebased. 154 | 155 | ## Links 156 | 157 | * [PowerShell Gallery | DockerCompletion](https://www.powershellgallery.com/packages/DockerCompletion) 158 | * [docker/cli](https://github.com/docker/cli) 159 | -------------------------------------------------------------------------------- /Tests/DockerCompletion.DOCKER_HIDE_LEGACY_COMMANDS.Tests.ps1: -------------------------------------------------------------------------------- 1 | #Requires -Module @{ ModuleName = 'Pester'; ModuleVersion = '5.1.1' } 2 | 3 | BeforeAll { 4 | $env:DOCKER_HIDE_LEGACY_COMMANDS = $true 5 | Import-Module $PSScriptRoot/../DockerCompletion -Force 6 | 7 | function Get-Result([string]$Text, [int]$CursorPosition = $Text.Length, [hashtable]$Options) { 8 | [System.Management.Automation.CommandCompletion]::CompleteInput($Text, $CursorPosition, $Options).CompletionMatches 9 | } 10 | } 11 | 12 | AfterAll { 13 | $env:DOCKER_HIDE_LEGACY_COMMANDS = $null 14 | } 15 | 16 | Describe 'docker' { 17 | It 'completes co' { 18 | $result = Get-Result 'docker co' 19 | $result | Should -HaveCount 4 20 | $result[0].CompletionText | Should -Be compose 21 | $result[1].CompletionText | Should -Be config 22 | $result[2].CompletionText | Should -Be container 23 | $result[3].CompletionText | Should -Be context 24 | } 25 | 26 | It 'completes s' { 27 | $result = Get-Result 'docker s' 28 | $result | Should -HaveCount 6 29 | $result[0].CompletionText | Should -Be secret 30 | $result[1].CompletionText | Should -Be service 31 | $result[2].CompletionText | Should -Be stack 32 | $result[3].CompletionText | Should -Be swarm 33 | $result[4].CompletionText | Should -Be system 34 | $result[5].CompletionText | Should -Be search 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Tests/DockerCompletion.Tests.ps1: -------------------------------------------------------------------------------- 1 | #Requires -Module @{ ModuleName = 'Pester'; ModuleVersion = '5.1.1' } 2 | 3 | BeforeAll { 4 | Import-Module $PSScriptRoot/../DockerCompletion -Force 5 | 6 | function Get-Result([string]$Text, [int]$CursorPosition = $Text.Length, [hashtable]$Options) { 7 | [System.Management.Automation.CommandCompletion]::CompleteInput($Text, $CursorPosition, $Options).CompletionMatches 8 | } 9 | } 10 | 11 | Describe 'docker' { 12 | It 'completes --t' { 13 | $result = Get-Result 'docker --t' 14 | $result | Should -HaveCount 5 15 | $result[0].CompletionText | Should -Be --tls 16 | $result[1].CompletionText | Should -Be --tlscacert 17 | $result[2].CompletionText | Should -Be --tlscert 18 | $result[3].CompletionText | Should -Be --tlskey 19 | $result[4].CompletionText | Should -Be --tlsverify 20 | } 21 | 22 | It 'completes co' { 23 | $result = Get-Result 'docker co' 24 | $result | Should -HaveCount 5 25 | $result[0].CompletionText | Should -Be compose 26 | $result[1].CompletionText | Should -Be config 27 | $result[2].CompletionText | Should -Be container 28 | $result[3].CompletionText | Should -Be context 29 | $result[4].CompletionText | Should -Be commit 30 | } 31 | } 32 | 33 | Describe 'docker compose' { 34 | It 'completes p' { 35 | $result = Get-Result 'docker compose p' 36 | $result | Should -HaveCount 6 37 | $result[0].CompletionText | Should -Be pause 38 | $result[1].CompletionText | Should -Be port 39 | $result[2].CompletionText | Should -Be ps 40 | $result[3].CompletionText | Should -Be publish 41 | $result[4].CompletionText | Should -Be pull 42 | $result[5].CompletionText | Should -Be push 43 | } 44 | 45 | It 'completes pu' { 46 | $result = Get-Result 'docker compose pu' 47 | $result | Should -HaveCount 3 48 | $result[0].CompletionText | Should -Be publish 49 | $result[1].CompletionText | Should -Be pull 50 | $result[2].CompletionText | Should -Be push 51 | } 52 | 53 | It 'completes --p' { 54 | $result = Get-Result 'docker compose --p' 55 | $result | Should -HaveCount 5 56 | $result[0].CompletionText | Should -Be --parallel 57 | $result[1].CompletionText | Should -Be --profile 58 | $result[2].CompletionText | Should -Be --progress 59 | $result[3].CompletionText | Should -Be --project-directory 60 | $result[4].CompletionText | Should -Be --project-name 61 | } 62 | 63 | It 'completes --progress' { 64 | $result = Get-Result 'docker compose --progress ' 65 | $result | Should -HaveCount 5 66 | $result[0].CompletionText | Should -Be auto 67 | $result[1].CompletionText | Should -Be json 68 | $result[2].CompletionText | Should -Be plain 69 | $result[3].CompletionText | Should -Be quiet 70 | $result[4].CompletionText | Should -Be tty 71 | } 72 | } 73 | 74 | Describe 'docker compose create' { 75 | It 'completes --pull' { 76 | $result = Get-Result 'docker compose create --pull ' 77 | $result | Should -HaveCount 4 78 | $result[0].CompletionText | Should -Be always 79 | $result[1].CompletionText | Should -Be build 80 | $result[2].CompletionText | Should -Be missing 81 | $result[3].CompletionText | Should -Be never 82 | } 83 | } 84 | 85 | Describe 'docker --log-level debug compose' { 86 | It 'completes c' { 87 | $result = Get-Result 'docker --log-level debug compose c' 88 | $result | Should -HaveCount 4 89 | $result[0].CompletionText | Should -Be commit 90 | $result[1].CompletionText | Should -Be config 91 | $result[2].CompletionText | Should -Be cp 92 | $result[3].CompletionText | Should -Be create 93 | } 94 | } 95 | 96 | Describe 'docker --log-level debug compose --file test.yaml' { 97 | It 'completes --profile' { 98 | $file = Join-Path $PSScriptRoot test.yaml 99 | $result = Get-Result "docker --log-level debug compose --file $file --profile " 100 | $result | Should -HaveCount 2 101 | $result[0].CompletionText | Should -Be dev-1 102 | $result[1].CompletionText | Should -Be dev-2 103 | } 104 | 105 | It 'completes l' { 106 | $file = Join-Path $PSScriptRoot test.yaml 107 | $result = Get-Result "docker --log-level debug compose --file $file l" 108 | $result | Should -HaveCount 2 109 | $result[0].CompletionText | Should -Be logs 110 | $result[1].CompletionText | Should -Be ls 111 | } 112 | 113 | It 'completes create' { 114 | $file = Join-Path $PSScriptRoot test.yaml 115 | $result = Get-Result "docker --log-level debug compose --file $file create " 116 | $result | Should -HaveCount 1 117 | $result[0].CompletionText | Should -Be web 118 | } 119 | } 120 | 121 | Describe 'docker container' { 122 | It 'completes s' { 123 | $result = Get-Result 'docker container s' 124 | $result | Should -HaveCount 3 125 | $result[0].CompletionText | Should -Be start 126 | $result[1].CompletionText | Should -Be stats 127 | $result[2].CompletionText | Should -Be stop 128 | } 129 | 130 | It 'completes sta' { 131 | $result = Get-Result 'docker container sta' 132 | $result | Should -HaveCount 2 133 | $result[0].CompletionText | Should -Be start 134 | $result[1].CompletionText | Should -Be stats 135 | } 136 | } 137 | 138 | Describe 'docker container run --mount' { 139 | It 'completes BLANK' { 140 | $result = Get-Result 'docker container run --mount ' 141 | $result | Should -HaveCount 13 142 | $i = 0 143 | $result[$i++].CompletionText | Should -Be type 144 | $result[$i++].CompletionText | Should -Be source 145 | $result[$i++].CompletionText | Should -Be src 146 | $result[$i++].CompletionText | Should -Be destination 147 | $result[$i++].CompletionText | Should -Be dst 148 | $result[$i++].CompletionText | Should -Be target 149 | $result[$i++].CompletionText | Should -Be readonly 150 | $result[$i++].CompletionText | Should -Be ro 151 | $result[$i++].CompletionText | Should -Be consistency 152 | $result[$i++].CompletionText | Should -Be volume-driver 153 | $result[$i++].CompletionText | Should -Be volume-label 154 | $result[$i++].CompletionText | Should -Be volume-nocopy 155 | $result[$i++].CompletionText | Should -Be volume-opt 156 | } 157 | 158 | It 'completes type=bind,' { 159 | $result = Get-Result 'docker container run --mount type=bind,' 160 | $result | Should -HaveCount 10 161 | $i = 0 162 | $result[$i++].CompletionText | Should -Be source 163 | $result[$i++].CompletionText | Should -Be src 164 | $result[$i++].CompletionText | Should -Be destination 165 | $result[$i++].CompletionText | Should -Be dst 166 | $result[$i++].CompletionText | Should -Be target 167 | $result[$i++].CompletionText | Should -Be readonly 168 | $result[$i++].CompletionText | Should -Be ro 169 | $result[$i++].CompletionText | Should -Be consistency 170 | $result[$i++].CompletionText | Should -Be bind-propagation 171 | $result[$i++].CompletionText | Should -Be bind-nonrecursive 172 | } 173 | 174 | It 'completes type=bind,s' { 175 | $result = Get-Result 'docker container run --mount type=bind,s' 176 | $result | Should -HaveCount 2 177 | $i = 0 178 | $result[$i++].CompletionText | Should -Be source 179 | $result[$i++].CompletionText | Should -Be src 180 | } 181 | 182 | It 'completes type=bind,ds' { 183 | $result = Get-Result 'docker container run --mount type=bind,ds' 184 | $result | Should -HaveCount 1 185 | $i = 0 186 | $result[$i++].CompletionText | Should -Be dst 187 | } 188 | 189 | It 'completes s[tab]rc=/path,dst=/path' { 190 | $result = Get-Result 'docker container run --mount src=/c/Users/matt9ucci,dst=/root' 30 191 | $result | Should -HaveCount 2 192 | $i = 0 193 | $result[$i++].CompletionText | Should -Be source 194 | $result[$i++].CompletionText | Should -Be src 195 | } 196 | 197 | It 'completes type=bind,src=/path,d[tab]st=/path' { 198 | $result = Get-Result 'docker container run --mount type=bind,src=/c/Users/matt9ucci,dst=/root' 63 199 | $result | Should -HaveCount 2 200 | $i = 0 201 | $result[$i++].CompletionText | Should -Be destination 202 | $result[$i++].CompletionText | Should -Be dst 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /Tests/test.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | web: 3 | build: . 4 | db: 5 | build: . 6 | profiles: ["dev-1", "dev-2"] 7 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt9ucci/DockerCompletion/cec4e39b7f763a6b57584400b1865349dc904a2d/demo.gif --------------------------------------------------------------------------------