summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-04-09 20:45:25 +0200
committerAlbert Cervin <albert@acervin.com>2024-04-09 20:46:52 +0200
commit5ac71eee1b31d42c2e094033f342a1adea6001ef (patch)
treedd45726c06d6ffbd1c267f6852aa45df42985969 /src/main
parent15a5d49e737965f0349504214a53b3311f73a694 (diff)
downloaddged-5ac71eee1b31d42c2e094033f342a1adea6001ef.tar.gz
dged-5ac71eee1b31d42c2e094033f342a1adea6001ef.tar.xz
dged-5ac71eee1b31d42c2e094033f342a1adea6001ef.zip
Prepare 0.1.0
Clarify a few things in the README.md and add a version macro that can be used with `-V/--version`.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/main.c14
-rw-r--r--src/main/version.h6
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/main.c b/src/main/main.c
index a020b9f..b0e408d 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -31,6 +31,7 @@
#include "bindings.h"
#include "cmds.h"
#include "completion.h"
+#include "version.h"
static struct frame_allocator frame_allocator;
@@ -121,16 +122,21 @@ void update_file_watches(struct reactor *reactor) {
}
}
-void usage() {
+static void usage() {
printf("dged - a text editor for datagubbar/datagummor!\n");
printf("usage: dged [-l/--line line_number] [-e/--end] [-h/--help] "
"[filename]\n");
}
+static void version() {
+ printf("dged - %s\n© Albert Cervin 2024\n", DGED_VERSION);
+}
+
int main(int argc, char *argv[]) {
static struct option longopts[] = {{"line", required_argument, NULL, 'l'},
{"end", no_argument, NULL, 'e'},
+ {"version", no_argument, NULL, 'V'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};
@@ -138,8 +144,12 @@ int main(int argc, char *argv[]) {
uint32_t jumpline = 1;
bool goto_end = false;
char ch;
- while ((ch = getopt_long(argc, argv, "hel:", longopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "Vhel:", longopts, NULL)) != -1) {
switch (ch) {
+ case 'V':
+ version();
+ return 0;
+ break;
case 'l':
jumpline = atoi(optarg);
break;
diff --git a/src/main/version.h b/src/main/version.h
new file mode 100644
index 0000000..cf77ce8
--- /dev/null
+++ b/src/main/version.h
@@ -0,0 +1,6 @@
+#ifndef _VERSION_H
+#define _VERSION_H
+
+#define DGED_VERSION "dev"
+
+#endif