mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-21 23:48:22 +08:00
Add -h/--help and -v/--version support to commandline tools
This commit is contained in:
parent
c4ed9c310d
commit
cb6ef45d0c
@ -30,11 +30,38 @@ enum ReadType {
|
||||
READ_SECTION
|
||||
};
|
||||
|
||||
void print_usage()
|
||||
{
|
||||
std::cout << "UEFIExtract " PROGRAM_VERSION << std::endl
|
||||
<< "Usage: UEFIExtract {-h | --help | -v | --version} - show help and/or version information." << std::endl
|
||||
<< " UEFIExtract imagefile - generate report and dump only leaf tree items into .dump folder." << std::endl
|
||||
<< " UEFIExtract imagefile all - generate report and dump all tree items." << std::endl
|
||||
<< " UEFIExtract imagefile unpack - generate report and dump all tree items in one dir." << std::endl
|
||||
<< " UEFIExtract imagefile dump - only generate dump, no report needed." << std::endl
|
||||
<< " UEFIExtract imagefile report - only generate report, no dump needed." << std::endl
|
||||
<< " UEFIExtract imagefile GUID_1 ... [ -o FILE_1 ... ] [ -m MODE_1 ... ] [ -t TYPE_1 ... ] -" << std::endl
|
||||
<< " Dump only FFS file(s) with specific GUID(s), without report." << std::endl
|
||||
<< " Type is section type or FF to ignore. Mode is one of: all, body, header, info, file." << std::endl
|
||||
<< "Return value is a bit mask where 0 at position N means that file with GUID_N was found and unpacked, 1 otherwise." << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initGuidDatabase("guids.csv");
|
||||
|
||||
if (argc > 1) {
|
||||
if (argc == 2) {
|
||||
UString arg = UString(argv[1]);
|
||||
if (arg == UString("-h") || arg == UString("--help")) {
|
||||
print_usage();
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else if (arg == UString("-v") || arg == UString("--version")) {
|
||||
std::cout << PROGRAM_VERSION << std::endl;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that input file exists
|
||||
USTATUS result;
|
||||
UByteArray buffer;
|
||||
@ -154,16 +181,8 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If parameters are different, show version and usage information
|
||||
std::cout << "UEFIExtract " PROGRAM_VERSION << std::endl << std::endl
|
||||
<< "Usage: UEFIExtract imagefile - generate report and dump only leaf tree items into .dump folder." << std::endl
|
||||
<< " UEFIExtract imagefile all - generate report and dump all tree items." << std::endl
|
||||
<< " UEFIExtract imagefile unpack - generate report and dump all tree items in one dir." << std::endl
|
||||
<< " UEFIExtract imagefile dump - only generate dump, no report needed." << std::endl
|
||||
<< " UEFIExtract imagefile report - only generate report, no dump needed." << std::endl
|
||||
<< " UEFIExtract imagefile GUID_1 ... [ -o FILE_1 ... ] [ -m MODE_1 ... ] [ -t TYPE_1 ... ] -" << std::endl
|
||||
<< " Dump only FFS file(s) with specific GUID(s), without report." << std::endl
|
||||
<< " Type is section type or FF to ignore. Mode is one of: all, body, header, info, file." << std::endl
|
||||
<< "Return value is a bit mask where 0 at position N means that file with GUID_N was found and unpacked, 1 otherwise." << std::endl;
|
||||
print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
@ -19,6 +19,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include "../common/guiddatabase.h"
|
||||
#include "uefifind.h"
|
||||
|
||||
void print_usage()
|
||||
{
|
||||
std::cout << "UEFIFind " PROGRAM_VERSION << std::endl <<
|
||||
"Usage: UEFIFind {-h | --help | -v | -version}" << std::endl <<
|
||||
" UEFIFind imagefile {header | body | all} {list | count} pattern" << std::endl <<
|
||||
" UEFIFind imagefile file patternsfile" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
UEFIFind w;
|
||||
@ -26,7 +34,22 @@ int main(int argc, char *argv[])
|
||||
|
||||
initGuidDatabase("guids.csv");
|
||||
|
||||
if (argc == 5) {
|
||||
if (argc == 1) {
|
||||
print_usage();
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else if (argc == 2) {
|
||||
UString arg = argv[1];
|
||||
if (arg == UString("-h") || arg == UString("--help")) {
|
||||
print_usage();
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else if (arg == UString("-v") || arg == UString("--version")) {
|
||||
std::cout << PROGRAM_VERSION << std::endl;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
}
|
||||
else if (argc == 5) {
|
||||
UString inputArg = argv[1];
|
||||
UString modeArg = argv[2];
|
||||
UString subModeArg = argv[3];
|
||||
@ -165,10 +188,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
return U_SUCCESS;
|
||||
}
|
||||
else {
|
||||
std::cout << "UEFIFind " PROGRAM_VERSION << std::endl << std::endl <<
|
||||
"Usage: UEFIFind imagefile {header | body | all} {list | count} pattern" << std::endl <<
|
||||
" or UEFIFind imagefile file patternsfile" << std::endl;
|
||||
|
||||
print_usage();
|
||||
return U_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user