Class: NitPicker::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/nitpicker.rb

Constant Summary collapse

CONFIG_DIR =
File.expand_path('~/.config/nitpicker')
PROMPT_FILE =
File.join(CONFIG_DIR, 'prompt')
REPO_PROMPT_FILE =
'.nitpicker_prompt'

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



14
15
16
17
# File 'lib/nitpicker.rb', line 14

def initialize
  @options = {}
  setup_config_dir
end

Instance Method Details

#parse_optionsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nitpicker.rb', line 19

def parse_options
  require 'optparse'
  
  OptionParser.new do |opts|
    opts.banner = 'Usage: nitpicker [options]'
    opts.version = VERSION

    opts.on('-h', '--help', 'Show this help message') do
      puts opts
      exit
    end
  end.parse!
end

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/nitpicker.rb', line 33

def run
  parse_options
  
  # Get git diff of staged changes
  diff = `git diff --staged`
  
  if diff.empty?
    puts "No changes staged for review."
    exit 1
  end

  # Get AI-generated code review
  review = generate_code_review(diff)
  
  # Display the review
  puts review
end