Add support for using an optional device descriptor
The device descriptor is either mandatory for a certain command (with DCTOOL_CONFIG_DESCRIPTOR) or always NULL. But for some commands it will be useful to support an optional descriptor as well. To support this, we always try to lookup the device descriptor whenever the corresponding command-line options are set.
This commit is contained in:
parent
0026fbd289
commit
54fef8e093
@ -275,14 +275,7 @@ main (int argc, char *argv[])
|
||||
dc_context_set_loglevel (context, loglevel);
|
||||
dc_context_set_logfunc (context, logfunc, NULL);
|
||||
|
||||
if (command->config & DCTOOL_CONFIG_DESCRIPTOR) {
|
||||
// Check mandatory arguments.
|
||||
if (device == NULL && family == DC_FAMILY_NULL) {
|
||||
message ("No device name or family type specified.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (device != NULL || family != DC_FAMILY_NULL) {
|
||||
// Search for a matching device descriptor.
|
||||
status = dctool_descriptor_search (&descriptor, device, family, model);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
@ -304,6 +297,13 @@ main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// Check mandatory descriptor arguments.
|
||||
if (command->config & DCTOOL_CONFIG_DESCRIPTOR && descriptor == NULL) {
|
||||
message ("No device name or family type specified.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Execute the command.
|
||||
exitcode = command->run (argc, argv, context, descriptor);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user