Up: libefi-argp
The small example below shows a program that accepts two options: --count and --verbose, with short versions -c and -v respectively.
static efi_argp_option_t options = [] { { L"count", 'c', 0, 0, L"Forward direction", L"NUM" }, { L"verbose", 'v', 0, 0, L"Verbose output", NULL }, { 0, 0, 0, 't', L"Text to display", L"TEXT" }, { 0, 0, 0, 0, 0, 0 } }; int count = 10; int verbose = 0; efi_char16_t *text = NULL; static efi_status_t parse (void *data, efi_argp_option_t *opt, efi_char16_t *arg) { switch (opt->shortarg) { case 'c': count = efi_wstrtoul (arg, NULL, 0); break; case 'v': verbose = 1; break; } switch (opt->key) { case 't': text = arg; break; } return EFI_SUCCESS; } efi_status_t efi_main (efi_handle_t image, int argc, efi_char16_t **argv) { efi_status_t err; int i; err = efi_argp_parse (argc, argv, options, parse, 0); if (err) return err; for (i = 0; i < count; i++) if (verbose) efi_printf (L"%s\n", text); return EFI_SUCCESS; }