// The second option should be either 'capture' or 'direction'
// if subcommand is neither 'version' nor 'help'.
if (subcmd != SUBCMD_VERSION && subcmd != SUBCMD_HELP) {
- if (!detect_direction(argc, argv, &direction))
+ if (!detect_direction(argc, argv, &direction)) {
subcmd = SUBCMD_HELP;
+ } else {
+ // argv[0] is needed for unparsed option to use
+ // getopt_long(3).
+ argc -= 2;
+ argv += 2;
+ }
}
}
};
int i;
- if (strcmp(argv[1], "list") || argc < 3)
+ if (argc < 2)
return false;
for (i = 0; i < ARRAY_SIZE(ops); ++i) {
- if (!strcmp(argv[2], ops[i])) {
+ if (!strcmp(argv[1], ops[i])) {
*op = i;
return true;
}
int err = 0;
// Renewed command system.
- if (argc > 1) {
- if (!detect_operation(argc, argv, &op) &&
- !decide_operation(argc, argv, &op))
- err = -EINVAL;
- }
+ if (!detect_operation(argc, argv, &op) &&
+ !decide_operation(argc, argv, &op))
+ err = -EINVAL;
if (op == LIST_OP_DEVICE)
err = list_devices(direction);
uint64_t actual_frame_count = 0;
int err = 0;
- // Renewed command system.
- if (argc > 2 && !strcmp(argv[1], "transfer")) {
- // Go ahead to parse file paths properly.
- --argc;
- ++argv;
- }
-
err = prepare_signal_handler(&ctx);
if (err < 0)
return err;