MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cli_strip_flag_value

Function cli_strip_flag_value

src/main.c:714–728  ·  view source on GitHub ↗

Strip a flag AND its following value from argv, returning the value (a pointer * into the original argv strings, valid for the process lifetime) or NULL if the * flag is absent. */

Source from the content-addressed store, hash-verified

712 * into the original argv strings, valid for the process lifetime) or NULL if the
713 * flag is absent. */
714static const char *cli_strip_flag_value(int *argc, char **argv, const char *flag) {
715 for (int i = 0; i < *argc; i++) {
716 if (strcmp(argv[i], flag) != 0) {
717 continue;
718 }
719 const char *value = (i + SKIP_ONE < *argc) ? argv[i + SKIP_ONE] : NULL;
720 int remove_count = value ? 2 : 1;
721 for (int j = i; j < *argc - remove_count; j++) {
722 argv[j] = argv[j + remove_count];
723 }
724 *argc -= remove_count;
725 return value;
726 }
727 return NULL;
728}
729
730/* Portable "is fd a terminal?" — _isatty on Windows, isatty on POSIX. */
731#ifdef _WIN32

Callers 1

run_cliFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected