Add console command with automatic endpoint resolution

portainer-cli console <stack> <container> looks up the stack by name to
find its endpoint ID automatically, so the user never needs to specify it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 13:01:41 +01:00
parent d3cb4fdebd
commit d8e00a4f1a
2 changed files with 122 additions and 2 deletions
+9 -2
View File
@@ -8,6 +8,7 @@ require_relative 'portainer_cli/commands/configure'
require_relative 'portainer_cli/commands/list'
require_relative 'portainer_cli/commands/create'
require_relative 'portainer_cli/commands/exec'
require_relative 'portainer_cli/commands/console'
module PortainerCli
module CLI
@@ -29,7 +30,9 @@ module PortainerCli
portainer-cli list networks <endpoint-id> List networks
portainer-cli create stack --endpoint ID --name NAME --file FILE
portainer-cli create container --endpoint ID --image IMAGE [--name NAME] [--port h:c] [--env K=V]
portainer-cli exec <endpoint-id> <container> Open interactive shell
portainer-cli console <stack> <container> Open interactive shell (resolves endpoint automatically)
--shell SHELL Shell to use (default: /bin/sh)
portainer-cli exec <endpoint-id> <container> Open interactive shell (manual endpoint)
--shell SHELL Shell to use (default: /bin/sh)
Config file: ~/.portainer-cli/config.yml
@@ -50,7 +53,11 @@ module PortainerCli
require_config!(config)
client = Client.new(config)
Commands::Create.new(config, client).run(argv)
when 'exec', 'shell', 'console'
when 'console'
require_config!(config)
client = Client.new(config)
Commands::Console.new(config, client).run(argv)
when 'exec', 'shell'
require_config!(config)
client = Client.new(config)
Commands::Exec.new(config, client).run(argv)