Skip to content

Commit b218e3b

Browse files
committed
Add --version and --help.
1 parent 188a0be commit b218e3b

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
/* Compile-time configuration */
55

6+
#ifndef ENCHIVE_VERSION
7+
# define ENCHIVE_VERSION 1.0
8+
#endif
9+
610
#ifndef ENCHIVE_RANDOM_DEVICE
711
# define ENCHIVE_RANDOM_DEVICE /dev/urandom
812
#endif

src/docs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ static const char *docs_usage[] = {
44
" [-a|--agent[=seconds]] [--no-agent]",
55
#endif
66
#if ENCHIVE_OPTION_RANDOM_DEVICE
7-
" [--random-device <file>]",
7+
" [--random-device <file>] "
8+
#else
9+
" "
810
#endif
11+
"[--version] [--help]",
912
" <command> [args]",
1013
"",
1114
"Commands (unique prefixes accepted):",
@@ -24,6 +27,8 @@ static const char *docs_usage[] = {
2427
#endif
2528
" --pubkey <file>, -p set the public key file [~/.enchive.pub]",
2629
" --seckey <file>, -s set the secret key file [~/.enchive.sec]",
30+
" --version display version information",
31+
" --help display this usage information",
2732
"",
2833
"Enchive archives files by encrypting them to yourself using your",
2934
"public key. It uses ChaCha20, Curve25519, and SHA-224.",

src/enchive.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,12 @@ print_usage(FILE *f)
11261126
multiputs(docs_usage, f);
11271127
}
11281128

1129+
static void
1130+
print_version(void)
1131+
{
1132+
puts("enchive " STR(ENCHIVE_VERSION));
1133+
}
1134+
11291135
int
11301136
main(int argc, char **argv)
11311137
{
@@ -1139,6 +1145,8 @@ main(int argc, char **argv)
11391145
#endif
11401146
{"pubkey", 'p', OPTPARSE_REQUIRED},
11411147
{"seckey", 's', OPTPARSE_REQUIRED},
1148+
{"version", 'V', OPTPARSE_NONE},
1149+
{"help", 'h', OPTPARSE_NONE},
11421150
{0, 0, 0}
11431151
};
11441152

@@ -1178,6 +1186,14 @@ main(int argc, char **argv)
11781186
case 's':
11791187
global_seckey = options->optarg;
11801188
break;
1189+
case 'h':
1190+
print_usage(stdout);
1191+
exit(EXIT_SUCCESS);
1192+
break;
1193+
case 'V':
1194+
print_version();
1195+
exit(EXIT_SUCCESS);
1196+
break;
11811197
default:
11821198
fatal("%s", options->errmsg);
11831199
}

src/sha256.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*********************************************************************
22
* Filename: sha256.c
33
* Author: Brad Conte (brad AT bradconte.com)
4-
* Copyright:
4+
* Copyright: Public Domain
55
* Disclaimer: This code is presented "as is" without any guarantees.
66
* Details: Implementation of the SHA-256 hashing algorithm.
77
SHA-256 is one of the three algorithms in the SHA2

src/sha256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*********************************************************************
22
* Filename: sha256.h
33
* Author: Brad Conte (brad AT bradconte.com)
4-
* Copyright:
4+
* Copyright: Public Domain
55
* Disclaimer: This code is presented "as is" without any guarantees.
66
* Details: Defines the API for the corresponding SHA1 implementation.
77
*********************************************************************/

0 commit comments

Comments
 (0)