프로그램 사용은 -d
옵션을 두 번 출력 하지만 struct poptOption
. 다음은 사용량 출력입니다.
Usage: generate-test [-d?] [-d|--data] [-n|--test-name=STRING] [-?|--help]
[--usage]
--help 출력이 올 바릅니다.
Usage: generate-test [OPTION...]
-d, --data Provide this option if the test needs external data from file(s)
-n, --test-name=STRING Provide a test name, this option is mandatory
Help options:
-?, --help Show this help message
--usage Display brief usage message
이것은 내 코드입니다.
char *test_name = NULL;
int use_external_data = 0;
struct poptOption popt_options[] = {
{"data", 'd', POPT_ARG_NONE, NULL, 2, "Provide this option if the test needs an external data from file(s)", NULL },
{"test-name", 'n', POPT_ARG_STRING, &test_name, 1, "Provide a test name, this option is mandatory", NULL },
POPT_AUTOHELP { NULL, '\0', 0, NULL, 0, NULL, NULL }
};
poptContext popt_context;
popt_context = poptGetContext("Test generator", argc, argv, popt_options, 0);
int opt_ret = 0;
while ((opt_ret = poptGetNextOpt(popt_context)) > 0)
switch (opt_ret)
{
case 2:
use_external_data = 1;
break;
}
POpt 라이브러리에 대해 이해하지 못하는 것은 무엇입니까? 감사!
혼란스러워 보일 수 있다는 데 동의합니다. 무엇 popt
으로 보여주는 것은 [-d?] [-d|--data]
것입니다 -d
짧은 옵션은 독립형 옵션이 될 수 있으며,이 같은 다른 짧은 옵션에 통합 할 수 있습니다 -?
(반대로 -n
).
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다