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 and validates worktree configuration. Shows current settings, configuration file locations, and validation results.

Examples:

Show current configuration

ConfigCommand.new.run(["--show"])

Validate configuration

ConfigCommand.new.run(["--validate"])

Instance Method Summary collapse

Constructor Details

#initializeConfigCommand

Initialize a new ConfigCommand



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

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)



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

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

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

  validate_options(options)

  results = []

  if options[:show]
    results << show_configuration
  end

  if options[:validate]
    results << validate_configuration
  end

  if options[:files]
    results << show_configuration_files
  end

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

#show_helpInteger

Show help for the config command

Returns:

  • (Integer)

    Exit code



65
66
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ace/git/worktree/commands/config_command.rb', line 65

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

    USAGE:
        ace-git-worktree config [OPTIONS]

    ACTIONS:
        --show                  Show current configuration (default)
        --validate              Validate configuration
        --files                 Show configuration file locations

    OPTIONS:
        --verbose, -v           Show detailed information
        --help, -h              Show this help message

    EXAMPLES:
        # Show current configuration
        ace-git-worktree config
        ace-git-worktree config --show

        # Validate configuration
        ace-git-worktree config --validate

        # Show configuration file locations
        ace-git-worktree config --files

        # Show everything
        ace-git-worktree config --show --validate --files

    CONFIGURATION FILES:
        .ace/git/worktree.yml          Project-specific configuration
        .ace-defaults/git/worktree.yml  Example configuration template
        ~/.ace/git/worktree.yml         User-specific configuration

    CONFIGURATION OPTIONS:
        git.worktree.root_path         Worktree root directory
        git.worktree.mise_trust_auto   Automatic mise trust
        git.worktree.task.*            Task-related settings
        git.worktree.cleanup.*         Cleanup behavior settings

    VALIDATION:
        Checks for:
        • Valid configuration structure
        • Required configuration fields
        • Accessible worktree root directory
        • Valid template variables
        • Consistent settings

    For configuration examples, see .ace-defaults/git/worktree.yml
  HELP
  0
end