[C++] Changes in the flathash program (#5255)

* Correct the usage in the flathash program

As it is possible to have -- before the occurrence of the first
input STRING.

* Exit with 1 in the flathash program when an error occurs
This commit is contained in:
Henry Lee 2019-03-22 10:23:32 +11:00 committed by Wouter van Oortmerssen
parent 440a70f4a3
commit a7461433c6
1 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ enum OutputFormat { kDecimal, kHexadecimal, kHexadecimal0x };
int main(int argc, char *argv[]) {
const char *name = argv[0];
if (argc <= 1) {
printf("%s HASH [OPTION]... STRING... [-- STRING...]\n", name);
printf("%s HASH [OPTION]... [--] STRING...\n", name);
printf("Available hashing algorithms:\n");
printf(" 16 bit:\n");
size_t size = sizeof(flatbuffers::kHashFunctions16) /
@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
" -x Output hash in hexadecimal.\n"
" -0x Output hash in hexadecimal and prefix with 0x.\n"
" -c Append the string to the output in a c-style comment.\n");
return 0;
return 1;
}
const char *hash_algorithm = argv[1];
@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
if (!hash_function16 && !hash_function32 && !hash_function64) {
printf("\"%s\" is not a known hash algorithm.\n", hash_algorithm);
return 0;
return 1;
}
OutputFormat output_format = kHexadecimal;