aboutsummaryrefslogtreecommitdiff
path: root/src/find.c
blob: 4387d3c9935bfd8475619f2484de37f7de60e945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <string.h>

#include "list_pkgs.h"
#include "lua_state.h"

void find(const char* arg) {
  init_lua_state();
  cache_repos();
  if (!arg) {
    for (size_t i = 0; i < cached_repos_count; i++) {
      printf("%s\n", cached_repos[i].source_key);
    }
    return;
  }
  for (size_t i = 0; i < cached_repos_count; i++) {
    if (!strstr(cached_repos[i].source_key, arg)) continue;
    printf("%s\n", cached_repos[i].source_key);
  }
}