summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-10-29 12:13:50 -0600
committerAaron Ball <nullspoon@oper.io>2018-10-29 12:13:50 -0600
commit19489e8e26cd3e6c6098ba4ae85536a4a56695ac (patch)
tree208f886e7592b302d1afe76f5c204d68bc0b84ae
parentc7b940e9baffca703c9a54aa3b3a2ca42482751c (diff)
downloadgpgedit-19489e8e26cd3e6c6098ba4ae85536a4a56695ac.tar.gz
gpgedit-19489e8e26cd3e6c6098ba4ae85536a4a56695ac.tar.xz
Implemented helptext
This documents program function, description, and basic usage with the two currently available switches, -r,--recipient and -h,--help.
-rw-r--r--TODO.adoc2
-rw-r--r--src/main.c22
2 files changed, 23 insertions, 1 deletions
diff --git a/TODO.adoc b/TODO.adoc
index 35fc661..aaf3b38 100644
--- a/TODO.adoc
+++ b/TODO.adoc
@@ -13,4 +13,4 @@ Implement
* [x] Recipient addition beyond the list already in the file
* [ ] Recipient removal from existing file
* [ ] New file creation (at least one recipient required)
-* [ ] Helptext
+* [x] Helptext
diff --git a/src/main.c b/src/main.c
index a5afe97..ca0df5c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,25 @@ void system_edit(char* file) {
}
+void usage() {
+ const char* helptext =
+ "GPGEdit is an editor wrapper for GPG encrypted files. It will decrypt the\n"
+ "specified text file to a secure location in memory, and open the specified\n"
+ "editor. Upon closing the editor, the unencrypted copy in memory is\n"
+ "re-encrypted, written back to the original encrypted location, and the\n"
+ "decrypted copy is deleted from memory.\n\n"
+ "NOTE: If power is lost while editing a file, all changes will be lost as\n"
+ "they are stored exclusively in memory.\n"
+ "\nUsage:\n\n"
+ " gpgedit [-r user@host] <file.gpg>\n"
+ "\nArguments:\n"
+ " -r,--recipient Adds a recipient key to the encrypted output\n"
+ " -h,--help Print this help text\n";
+
+ printf("%s\n", helptext);
+}
+
+
void parseargs(int argc, char* argv[], struct gpgedit_config* config) {
int i = 1;
@@ -39,6 +58,9 @@ void parseargs(int argc, char* argv[], struct gpgedit_config* config) {
i++;
//printf("Adding recipient %s\n", argv[i]);
strll_add(config->recipients, argv[i]);
+ } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
+ usage();
+ exit(0);
} else {
gpgedit_config_file_set(config, argv[i]);
}

Generated by cgit