#!/usr/bin/env nu

def main [] {
}

def "main help" [] {
  main release
  ./target/release/llm-lsp -h
}

def "main list-providers" [] {
  main release
  ./target/release/llm-lsp list-providers
}

def "main generate-config" [] {
  main release
  ./target/release/llm-lsp generate-config
}

def "main debug" [] {
  cargo build
}

def "main release" [] {
  cargo build --release
}

def "main install" [] {
  main release
  if ('~/bin/llm-lsp' | path exists) {
    rm ~/bin/llm-lsp
  }
  cp target/release/llm-lsp ~/bin/
}

def "main install-debug" [] {
  main debug
  if ('~/bin/llm-lsp' | path exists) {
    rm ~/bin/llm-lsp
  }
  cp target/debug/llm-lsp ~/bin/
}

def "main register" [] {
  http post --content-type application/json https://api.codeium.com/register_user/ { firebase_id_token: ey.... }
}

def "main completion" [] {
  http post --content-type application/json --headers ["Authorization" "Basic 38905d20-ab5a-4738-a8e1-f79d9ea276bd-a"] https://web-backend.codeium.com { firebase_id_token: ey.... }
}

def "main clean-tail" [] {
  main install-debug
  "" | save -f ~/.cache/helix/helix.log
  tail -f ~/.cache/helix/helix.log
}
