aboutsummaryrefslogtreecommitdiff
path: root/src/find.c
diff options
context:
space:
mode:
authordacctal <dacctal@symlinx.net>2026-05-25 13:32:21 +0000
committerdacctal <dacctal@symlinx.net>2026-05-25 13:32:21 +0000
commitd8193b7bf893d0c4f3a508dc1eacf44a40cbfef3 (patch)
treea3bd6f3986e10962db3f7920d25b2c9bca3b5353 /src/find.c
parentd864bf7907c814eef30e906e59b0890df34d311c (diff)
'find' will search repo for argument, 'list' will list all installed packages
Diffstat (limited to 'src/find.c')
-rw-r--r--src/find.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/find.c b/src/find.c
index aaeaaa2..4387d3c 100644
--- a/src/find.c
+++ b/src/find.c
@@ -1,23 +1,20 @@
-#include <dirent.h>
#include <stdio.h>
#include <string.h>
-#include <sys/stat.h>
+#include "list_pkgs.h"
#include "lua_state.h"
-#include "vars.h"
-void find() {
- char* src_code = map_get(&cached_install_directories, "src");
- struct dirent* dirent_ptr;
- DIR* dir_ptr = opendir(src_code);
-
- if (dir_ptr == NULL) {
- fprintf(stderr, "%scould not open %s\n", print_pkgit, src_code);
+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;
}
-
- while ((dirent_ptr = readdir(dir_ptr)) != NULL) {
- if (strcmp(dirent_ptr->d_name, "..") == 0 || strcmp(dirent_ptr->d_name, ".") == 0) { continue; }
- printf("%s\n", dirent_ptr->d_name);
+ 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);
}
}