Class: Kanayago::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
15
# File 'lib/kanayago/cli.rb', line 11

def initialize(argv)
  @argv = argv
  @file = nil
  @lsp_mode = false
end

Class Method Details

.start(argv) ⇒ Object



7
8
9
# File 'lib/kanayago/cli.rb', line 7

def self.start(argv)
  new(argv).run
end

Instance Method Details

#runObject



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
# File 'lib/kanayago/cli.rb', line 17

def run
  # Check for --lsp flag first
  parse_global_options

  if @lsp_mode
    start_lsp_server
    return
  end

  if @argv.empty?
    puts "Usage: kanayago check 'code' or kanayago check --file FILE"
    puts '       kanayago --lsp (start LSP server)'
    exit 1
  end

  command = @argv.shift

  case command
  when 'check'
    check_command
  else
    puts "Unknown command: #{command}"
    puts "Usage: kanayago check 'code' or kanayago check --file FILE"
    puts '       kanayago --lsp (start LSP server)'
    exit 1
  end
end