Add --version and --help.

pull/2/head 1.0
Christopher Wellons 2017-03-05 21:02:00 -05:00
parent 188a0be098
commit b218e3be80
5 changed files with 28 additions and 3 deletions

View File

@ -3,6 +3,10 @@
/* Compile-time configuration */
#ifndef ENCHIVE_VERSION
# define ENCHIVE_VERSION 1.0
#endif
#ifndef ENCHIVE_RANDOM_DEVICE
# define ENCHIVE_RANDOM_DEVICE /dev/urandom
#endif

View File

@ -4,8 +4,11 @@ static const char *docs_usage[] = {
" [-a|--agent[=seconds]] [--no-agent]",
#endif
#if ENCHIVE_OPTION_RANDOM_DEVICE
" [--random-device <file>]",
" [--random-device <file>] "
#else
" "
#endif
"[--version] [--help]",
" <command> [args]",
"",
"Commands (unique prefixes accepted):",
@ -24,6 +27,8 @@ static const char *docs_usage[] = {
#endif
" --pubkey <file>, -p set the public key file [~/.enchive.pub]",
" --seckey <file>, -s set the secret key file [~/.enchive.sec]",
" --version display version information",
" --help display this usage information",
"",
"Enchive archives files by encrypting them to yourself using your",
"public key. It uses ChaCha20, Curve25519, and SHA-224.",

View File

@ -1126,6 +1126,12 @@ print_usage(FILE *f)
multiputs(docs_usage, f);
}
static void
print_version(void)
{
puts("enchive " STR(ENCHIVE_VERSION));
}
int
main(int argc, char **argv)
{
@ -1139,6 +1145,8 @@ main(int argc, char **argv)
#endif
{"pubkey", 'p', OPTPARSE_REQUIRED},
{"seckey", 's', OPTPARSE_REQUIRED},
{"version", 'V', OPTPARSE_NONE},
{"help", 'h', OPTPARSE_NONE},
{0, 0, 0}
};
@ -1178,6 +1186,14 @@ main(int argc, char **argv)
case 's':
global_seckey = options->optarg;
break;
case 'h':
print_usage(stdout);
exit(EXIT_SUCCESS);
break;
case 'V':
print_version();
exit(EXIT_SUCCESS);
break;
default:
fatal("%s", options->errmsg);
}

View File

@ -1,7 +1,7 @@
/*********************************************************************
* Filename: sha256.c
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Copyright: Public Domain
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Implementation of the SHA-256 hashing algorithm.
SHA-256 is one of the three algorithms in the SHA2

View File

@ -1,7 +1,7 @@
/*********************************************************************
* Filename: sha256.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Copyright: Public Domain
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding SHA1 implementation.
*********************************************************************/