Implement info command in aaruformattool to dump all internal information from and image, and the library's context.

This commit is contained in:
2022-10-03 21:30:50 +01:00
parent 32e0f3f5bf
commit 1451a249a1
4 changed files with 552 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ void usage()
printf("\n");
printf("Available verbs:\n");
printf("\tidentify\tIdentifies if the indicated file is a supported AaruFormat image.\n");
printf("\tinfo\tPrints information about a given AaruFormat image.\n");
printf("\n");
printf("For help on the verb invoke the tool with the verb and no arguments.\n");
}
@@ -47,6 +48,17 @@ void usage_identify()
printf("\t<filename>\tPath to file to identify if it is a supported AaruFormat image.\n");
}
void usage_info()
{
printf("\n");
printf("Usage:\n");
printf("aaruformattool info <filename>\n");
printf("Prints information about a given AaruFormat image.\n");
printf("\n");
printf("Arguments:\n");
printf("\t<filename>\tPath to AaruFormat image to print information from.\n");
}
int main(int argc, char* argv[])
{
printf("AaruFormat Tool version %d.%d\n", AARUFORMAT_TOOL_MAJOR_VERSION, AARUFORMAT_TOOL_MINOR_VERSION);
@@ -78,5 +90,25 @@ int main(int argc, char* argv[])
return identify(argv[2]);
}
if(strncmp(argv[1], "info", strlen("info")) == 0)
{
if(argc == 2)
{
usage_info();
return -1;
}
if(argc > 3)
{
fprintf(stderr, "Invalid number of arguments\n");
usage_info();
return -1;
}
return info(argv[2]);
}
return 0;
}