Class: Ace::Git::Worktree::Commands::ConfigCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/git/worktree/commands/config_command.rb

Overview

Config command

Displays, initializes, updates, and validates worktree configuration. Shows current settings, provenance tracking, and validation results.

Instance Method Summary collapse

Constructor Details

#initializeConfigCommand

Initialize a new ConfigCommand



18
19
20
# File 'lib/ace/git/worktree/commands/config_command.rb', line 18

def initialize
  @manager = Organisms::WorktreeManager.new
end

Instance Method Details

#run(args = []) ⇒ Integer

Run the config command

Parameters:

  • args (Array<String>) (defaults to: [])

    Command arguments

Returns:

  • (Integer)

    Exit code (0 for success, 1 for error)



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
62
# File 'lib/ace/git/worktree/commands/config_command.rb', line 26

def run(args = [])
  options = parse_arguments(args)
  return show_help if options[:help]

  if options[:init]
    return init_project_config
  end

  if options[:set_bootstrap]
    return set_bootstrap_config(options)
  end

  # Default to showing configuration if no action specified
  options[:show] = true unless options[:validate] || options[:show] || options[:files]

  results = []

  if options[:show]
    results << show_configuration(json: options[:json])
  end

  if options[:validate]
    results << validate_configuration(bootstrap_only: options[:bootstrap], json: options[:json])
  end

  if options[:files]
    results << show_configuration_files
  end

  (results.all? { |result| result == 0 }) ? 0 : 1
rescue ArgumentError => e
  puts "Error: #{e.message}"
  1
rescue => e
  puts "Error: #{e.message}"
  1
end

#show_helpInteger

Show help for the config command

Returns:

  • (Integer)

    Exit code



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ace/git/worktree/commands/config_command.rb', line 67

def show_help
  puts <<~HELP
    ace-git-worktree config - Manage worktree configuration

    USAGE:
        ace-git-worktree config [SUBCOMMAND / OPTIONS]

    ACTIONS:
        init                                    Initialize minimal project worktree configuration
        set-bootstrap                           Set bootstrap command policy
        --show                                  Show current configuration (default)
        --validate                              Validate configuration
        --files                                 Show configuration file locations

    SET BOOTSTRAP OPTIONS:
        --command <cmd>                         Command to run
        --working-dir <path>                    Working directory relative to project root
        --timeout <sec>                         Timeout in seconds (max 300)
        --required | --advisory                 Policy for execution failure
        --env KEY=VALUE                         Environment variables

    FORMAT OPTIONS:
        --json                                  Format output as JSON
        --bootstrap                             Validate bootstrap section only

    EXAMPLES:
        ace-git-worktree config init
        ace-git-worktree config set-bootstrap --command "npm install" --timeout 120 --required
        ace-git-worktree config show --json
        ace-git-worktree config validate --bootstrap --json
  HELP
  0
end