Class: Pvectl::Commands::Config::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/pvectl/commands/config/command.rb

Overview

Registers the ‘pvectl config` command group with all subcommands.

Examples:

Commands::Config::Command.register(cli)

Class Method Summary collapse

Class Method Details

.register(cli) ⇒ void

This method returns an undefined value.

Registers the config command and all subcommands with the CLI.

Parameters:

  • cli (GLI::App)

    the CLI application object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pvectl/commands/config/command.rb', line 16

def self.register(cli)
  cli.desc "Manage pvectl configuration"
  cli.long_desc <<~HELP
    Manage pvectl configuration. Configuration uses kubeconfig-style
    contexts to support multiple Proxmox clusters.

    Configuration file location: ~/.pvectl/config

    SUBCOMMANDS
      config get-contexts       List all available contexts
      config use-context NAME   Switch to a different context
      config set-context NAME   Create or modify a context
      config set-cluster NAME   Create or modify a cluster definition
      config set-credentials NAME  Create or modify user credentials
      config view               Display current configuration (secrets masked)

    EXAMPLES
      View current configuration:
        $ pvectl config view

      Switch to a different context:
        $ pvectl config use-context production

      Set up a new cluster:
        $ pvectl config set-cluster prod --server=https://pve.example.com:8006
        $ pvectl config set-credentials admin --token-id=root@pam!pvectl --token-secret=xxx
        $ pvectl config set-context prod --cluster=prod --user=admin

    NOTES
      On first run, pvectl launches an interactive wizard if no config exists.

      Environment variables (PROXMOX_HOST, PROXMOX_TOKEN_ID, etc.) override
      config file values. Use PVECTL_CONTEXT to override the active context.

    SEE ALSO
      pvectl help ping          Test connectivity after configuration
  HELP
  cli.command :config do |c|
    UseContext.register_subcommand(c)
    GetContexts.register_subcommand(c)
    SetContext.register_subcommand(c)
    SetCluster.register_subcommand(c)
    SetCredentials.register_subcommand(c)
    View.register_subcommand(c)
  end
end