#!/usr/bin/env nu

let base_url = "https://media-browser.internal.kempkens.network/management/jobs/BdfrDownload/run?"

def "main subreddit" [
  subreddit: string
  --sort: string = "hot"
  --limit: int = 999
] {
  let url = $"($base_url)args[subreddit]=($subreddit)&args[sort]=($sort)&args[limit]=($limit)"

  http get $url | ignore
}

def "main user" [
  user: string
  --limit: int = 9999
] {
  let url = $"($base_url)args[user]=($user)&args[limit]=($limit)"

  http get $url | ignore
}

def "main search" [
  subreddit: string
  search: string
  --limit: int = 9999
] {
  let url = $"($base_url)args[subreddit]=($subreddit)&args[search]=($search)&args[limit]=($limit)"

  http get $url | ignore
}

def "main post" [
  post: string
] {
  let reddit_url = $post | url encode
  let url = $"($base_url)args[link]=($reddit_url)"

  http get $url | ignore
}

def main [] {}