diff options
| author | forever2k38 <forever2k38@noreply.codeberg.org> | 2026-08-31 10:19:12 +0200 |
|---|---|---|
| committer | forever2k38 <forever2k38@noreply.codeberg.org> | 2026-08-31 10:19:12 +0200 |
| commit | 8f5dc1930debe95e106595da33951bd870672d85 (patch) | |
| tree | bdf128ac0e079de2e2be7180c85037c15d4c7572 /src/args.c | |
| parent | b09a640e1dd7b30ff05093e14190da99bb3cac32 (diff) | |
feat: find package by name
Diffstat (limited to 'src/args.c')
| -rw-r--r-- | src/args.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -3,6 +3,7 @@ #include "stdbool.h" #include "stdio.h" #include "string.h" +#include "utils.h" char *help = "▄▄▄▄▄▄▄▄▄▄▄ ▄\n" "█ █ █ ▄ █\n" @@ -22,6 +23,7 @@ int pow_args_parse(int argc, char **argv, pow_args *args) { int flags = 0; bool next_flag_config; + bool next_flag_package; for (int i = 0; i < argc; i++) { char *arg = argv[i]; @@ -40,6 +42,20 @@ int pow_args_parse(int argc, char **argv, pow_args *args) { continue; } + if (next_flag_package) { + if (!strncmp(arg, "-", sizeof("-") - 1)) { + printf("Missing package argument\n"); + + return 1; + } + + args->package = arg; + + next_flag_package = false; + + continue; + } + if (strcmp(arg, "--help") == 0) { flags |= POW_FLAG_HELP; @@ -51,6 +67,36 @@ int pow_args_parse(int argc, char **argv, pow_args *args) { continue; } + + if (string_has_prefix("-", arg)) { + size_t len = strlen(arg); + + for (size_t j = 0; j < len; j++) { + char c = (char)arg[j]; + + switch (c) { + case 'S': { + if (flags & POW_FLAG_SYNC) { + printf("flag double defined, skipping\n"); + } + + flags |= POW_FLAG_SYNC; + next_flag_package = true; + }; + case 'Q': { + if (flags & POW_FLAG_QUERY) { + printf("flag double defined, skipping\n"); + + flags |= POW_FLAG_QUERY; + + next_flag_package = true; + } + } + } + } + + continue; + } } if (next_flag_config) { |
