Skip to content

Commit

Permalink
finish cmd-help-fix (#120)
Browse files Browse the repository at this point in the history
finish fixing `cmd help` seg fault for remaining commands
  • Loading branch information
liquidaty authored Mar 22, 2023
1 parent e5fbdad commit c3fd40e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ int ZSV_CLI_MAIN(int argc, const char *argv[]) {
};
if(help_builtin->main)
return help_builtin->main(2, argv_tmp);
else if(help_builtin->cmd)
return help_builtin->cmd(2, argv_tmp, NULL, NULL);
else
else if(help_builtin->cmd) {
char opts_used[ZSV_OPTS_SIZE_MAX] = { 0 };
struct zsv_opts opts = { 0 };
return help_builtin->cmd(2, argv_tmp, &opts, opts_used);
} else
return fprintf(stderr, "Unexpected syntax!\n");
} else {
const char *ext_cmd = extension_cmd_from_arg(argv[2]);
Expand Down
2 changes: 2 additions & 0 deletions app/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ test-cli: ${CLI}
@[ "${CLI}" = "" ] && echo 1>&2 'test-cli: missing CLI env var' && exit 1 || exit 0
@$< help select 2>&1 > ${TMP_DIR}/$@.out
@[ "`head -1 ${TMP_DIR}/$@.out`" = "select: streaming CSV parser" ] && [ $$(( `cat ${TMP_DIR}/$@.out | wc -l` )) = "35" ] && ${TEST_PASS} || ${TEST_FAIL}
@$< help count 2>&1 > ${TMP_DIR}/$@.out
@[ "`head -1 ${TMP_DIR}/$@.out`" = "Usage: count [options]" ] && [ $$(( `cat ${TMP_DIR}/$@.out | wc -l` )) = "5" ] && ${TEST_PASS} || ${TEST_FAIL}

test-1-count test-1-count-pull: test-1-% : ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv
@${TEST_INIT}
Expand Down

0 comments on commit c3fd40e

Please sign in to comment.