in src/main.c [36:110]
int main(int argc, char **argv)
{
bool udev_mode = false;
struct context ctx = {.output_format = PLAIN};
int opt;
int option_index = 0;
// clang-format off
static struct option long_options[] = {
{"debug", no_argument, 0, 'd'},
{"udev", no_argument, 0, 'u'},
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'},
{0, 0, 0, 0}};
// clang-format on
while ((opt = getopt_long(argc, argv, "duvhf:", long_options, &option_index)) != -1)
{
switch (opt)
{
case 'd':
debug = true;
break;
case 'u':
udev_mode = true;
break;
case 'v':
print_version(argv[0]);
return 0;
case 'h':
print_help(argv[0]);
return 0;
case 'f':
if (strcmp(optarg, "json") == 0)
{
ctx.output_format = JSON;
}
else if (strcmp(optarg, "plain") == 0)
{
ctx.output_format = PLAIN;
}
else
{
print_invalid_argument(argv[0], optarg);
return 1;
}
break;
default:
// Error for invalid --args
print_invalid_argument(argv[0], argv[optind - 1]);
return 1;
}
}
// Error for unparsed args
if (optind < argc)
{
print_invalid_argument(argv[0], argv[optind]);
return 1;
}
if (debug)
{
debug_environment_variables();
}
if (udev_mode)
{
return identify_udev_device();
}
return identify_disks(&ctx);
}