Class: AirTest::CLI

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

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



10
11
12
13
# File 'lib/air_test/cli.rb', line 10

def initialize
  @prompt = TTY::Prompt.new
  load_env_files
end

Instance Method Details

#create_pr(args) ⇒ Object



82
83
84
85
86
# File 'lib/air_test/cli.rb', line 82

def create_pr(args)
  puts "#{CYAN}šŸš€ Creating Pull Request...#{RESET}\n"
  # TODO: Implement create_pr functionality
  puts "#{YELLOW}āš ļø  create-pr command not yet implemented.#{RESET}"
end

#generate(args) ⇒ Object



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
72
73
74
75
76
77
78
79
80
# File 'lib/air_test/cli.rb', line 47

def generate(args)
  puts "#{CYAN}šŸ” Generating specs from tickets...#{RESET}\n"
  
  # Parse arguments
  options = parse_generate_options(args)
  
  # Load configuration
  config = load_configuration
  
  # Validate configuration
  validate_configuration(config)
  
  # Initialize AirTest configuration
  initialize_airtest_config(config)
  
  # Fetch tickets based on tool
  tickets = fetch_tickets(config, options)
  
  if tickets.empty?
    puts "#{YELLOW}āš ļø  No tickets found matching your criteria.#{RESET}"
    return
  end
  
  # Handle interactive selection or search results
  selected_tickets = select_tickets(tickets, options)
  
  if selected_tickets.empty?
    puts "#{YELLOW}āš ļø  No tickets selected.#{RESET}"
    return
  end
  
  # Process selected tickets
  process_tickets(selected_tickets, config, options)
end

#init(silent: false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/air_test/cli.rb', line 15

def init(silent: false)
  puts "#{CYAN}šŸš€ Initializing AirTest for your Rails project...#{RESET}\n"

  if silent
    # Set default values for silent mode
    config = {
      tool: 'notion',
      auto_pr: 'no',
      dev_assignee: 'default_assignee',
      interactive_mode: 'no'
    }
  else
    # Interactive prompts
    config = prompt_for_configuration
  end

  # Create configuration files
  create_airtest_yml(config)
  create_initializer_file
  create_env_example_file(config[:tool])
  create_directories

  # Check environment variables
  check_environment_variables(config[:tool])

  puts "\n✨ All set! Next steps:"
  puts "  1. Fill in your config/initializers/air_test.rb"
  puts "  2. Add your tokens to .env or your environment"
  puts "  3. Run: bundle exec rake air_test:generate_specs_from_notion"
  puts "\nHappy testing! šŸŽ‰"
end