Class: CommitGpt::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/commitgpt/cli.rb

Overview

CommitGpt CLI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.help(shell, _subcommand = false) ⇒ Object

Custom help message



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
63
64
65
66
67
68
69
70
71
# File 'lib/commitgpt/cli.rb', line 35

def self.help(shell, _subcommand = false)
  shell.say 'Usage:'
  shell.say '  aicm                     # Generate AI commit message (Default)'
  shell.say '  aicm setup               # Configure AI provider and settings'
  shell.say '  aicm help [COMMAND]      # Describe available commands'
  shell.say ''
  shell.say 'Options:'
  shell.say '  -m, --models             # Interactive model selection'
  shell.say '  -p, --provider           # Switch active provider'
  shell.say '  -f, --format             # Choose commit message format'
  shell.say '  -v, --verbose            # Show git diff being sent to AI'
  shell.say ''

  # Show current configuration
  begin
    require 'commitgpt/config_manager'
    require 'commitgpt/string'
    config = CommitGpt::ConfigManager.get_active_provider_config
    if config
      require 'commitgpt/version'
      shell.say "CommitGPT v#{CommitGpt::VERSION}"
      shell.say "Bin Path: #{File.realpath($PROGRAM_NAME)}".gray
      shell.say ''

      format = CommitGpt::ConfigManager.get_commit_format
      shell.say 'Current Configuration:'
      shell.say "  Provider:  #{config['name'].green}"
      shell.say "  Model:     #{config['model'].cyan}"
      shell.say "  Format:    #{format.capitalize.yellow}"
      shell.say "  Base URL:  #{config['base_url']}"
      shell.say "  Diff Len:  #{config['diff_len']}"
      shell.say ''
    end
  rescue StandardError
    # Ignore errors during help display if config is missing/invalid
  end
end

Instance Method Details

#generateObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/commitgpt/cli.rb', line 17

def generate
  if options[:provider]
    CommitGpt::SetupWizard.new.switch_provider
  elsif options[:models]
    CommitGpt::SetupWizard.new.change_model
  elsif options[:format]
    CommitGpt::SetupWizard.new.choose_format
  else
    CommitGpt::CommitAi.new.aicm(verbose: options[:verbose])
  end
end

#setupObject



30
31
32
# File 'lib/commitgpt/cli.rb', line 30

def setup
  CommitGpt::SetupWizard.new.run
end