Class: Pvectl::Commands::Config::View

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

Overview

Handler for the ‘pvectl config view` command.

Displays the current configuration with secrets masked. Secrets (token-secret, password) are replaced with ********.

Examples:

Usage

pvectl config view
pvectl config view -o json

Class Method Summary collapse

Class Method Details

.execute(global_options) ⇒ Integer

Executes the view command.

Parameters:

  • global_options (Hash)

    global CLI options (includes :config, :output)

Returns:

  • (Integer)

    exit code (0 for success)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pvectl/commands/config/view.rb', line 45

def self.execute(global_options)
  config_path = global_options[:config]
  output_format = global_options[:output] || "yaml"

  service = Pvectl::Config::Service.new
  service.load(config: config_path)

  masked_config = service.masked_config

  case output_format
  when "json"
    puts JSON.pretty_generate(masked_config)
  else
    # Default to YAML for human-readable output
    puts masked_config.to_yaml
  end

  0
end

.register_subcommand(parent) ⇒ void

This method returns an undefined value.

Registers the view subcommand.

Parameters:

  • parent (GLI::Command)

    parent config command



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pvectl/commands/config/view.rb', line 23

def self.register_subcommand(parent)
  parent.desc "Display current configuration with masked secrets"
  parent.long_desc <<~HELP
    Display the current configuration file contents. Secrets (token
    secrets, passwords) are masked for security.

    EXAMPLES
      $ pvectl config view
      $ pvectl config view -o yaml
  HELP
  parent.command :view do |view|
    view.action do |global_options, _options, _args|
      exit_code = execute(global_options)
      exit exit_code if exit_code != 0
    end
  end
end