poe

Уређивач .po фајлова
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 3a981b7348e3f69bd11472a38334d1cf195c32ef
родитељ 02e7b11eade0d0f4e5619e36ee965922de35f59b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed, 16 Jun 2021 14:12:49 +0200

Added --help, --version

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M.gitignore | 1+
Mall.do | 6+-----
Mdefault.h.do | 15+++++++++++----
Mdefault.o.do | 2+-
Dpoe.1 | 36------------------------------------
Mpoe.1.in | 15+++++++++++++++
Mpoe.c | 27++++++++++++++++++++++++++-
Mpoe.do | 5+++--
Aversion.h | 5+++++
Aversion.h.in | 5+++++
измењених датотека: 10, додавања: 68(+), брисања: 49(-)

diff --git a/.gitignore b/.gitignore @@ -13,6 +13,7 @@ nohup.out *.gz *.xz +*.1 poe date version diff --git a/all.do b/all.do @@ -1,6 +1,2 @@ -redo-ifchange config.def.h config.h -for f in *.c; do - echo $f | sed -e's/\.c$/.o/g' -done | xargs redo-ifchange -redo-ifchange poe +redo-ifchange poe poe.1.gz diff --git a/default.h.do b/default.h.do @@ -1,6 +1,13 @@ -redo-ifchange $2.def.h -if [ -f $2.def.h ]; then - cat $2.def.h > $3 +if [ -r $1.in ]; then + redo-ifchange $1.in version date + read VERSION <version + read DATE <date + sed -e "s/%VERSION%/$VERSION/g" \ + -e "s/%DATE%/$DATE/g" <$1.in +else + if [ -f $2.def.h ]; then + redo-ifchange $2.def.h + cat $2.def.h > $3 + fi fi - diff --git a/default.o.do b/default.o.do @@ -1,3 +1,3 @@ redo-ifchange $2.c -gcc -g -Wall -std=c99 -c $2.c -o $3 +${POE_CC:-gcc} -g -Wall -std=c99 -c $2.c -o $3 diff --git a/poe.1 b/poe.1 @@ -1,36 +0,0 @@ -'\" -.\" -. -.mso an-ext.tmac -. -.TH POE "1" "16 Jun 2021" "poe 0.1-alpha" "General Commands Manual" -.SH NAME -poe \- .po file editor -. -.SH SYNOPSIS -. -.SY poe -.YS -. -.SH COPYRIGHT -poe Copyright \(co 2021 Strahinya Radich. -.br -This program is licensed under GNU GPL v3 or later. See the file -.I LICENSE -in the poe repository for details. -. -.SH DESCRIPTION -.B poe -is a .po (GNU Gettext) file editor with a terminal UI. -. -.SH "KNOWN LIMITATIONS" -. -.SH BUGS -. -.LP -Bugs can be reported using the ticket tracker at: -.UR https://\:sr.ht/\:~strahinja/\:poe/\:trackers -.UE - -.\" vim: set filetype=groff: - diff --git a/poe.1.in b/poe.1.in @@ -10,6 +10,15 @@ poe \- .po file editor .SH SYNOPSIS . .SY poe +.OP "\-h \fR|\fP \-\-help" +.YS +. +.SY poe +.OP "\-v \fR|\fP \-\-version" +.YS +. +.SY poe +.RI [ filename.po ] .YS . .SH COPYRIGHT @@ -24,6 +33,12 @@ in the poe repository for details. is a .po (GNU Gettext) file editor with a terminal UI. . .SH "KNOWN LIMITATIONS" +.IP \(bu 4 +This project is currently (Jun 2021) still a work in progress. +. +.IP \(bu +Only one file can be edited at a time, and files can't be loaded at runtime. +This is a design decision. . .SH BUGS . diff --git a/poe.c b/poe.c @@ -12,6 +12,7 @@ #include <sys/stat.h> #include <time.h> +#include "version.h" #include "termbox.h" #include "util.h" #include "po.h" @@ -34,6 +35,21 @@ print_error(const int code, const char* msg, ...) return code; } +int +version() +{ + printf("%s v%s, built on %s\n", program_name, VERSION, DATE); + return 0; +} + +int +usage() +{ + printf("Usage: %s [-h|--help] [-v|--version] [filename.po]\n", + program_name); + return 0; +} + void format_filename(char* result, size_t result_size, const char* format, const struct DrawState* state) @@ -209,7 +225,16 @@ main(int argc, char** argv) prompt[0] = 0; filename[0] = 0; - if (argc > 1) + if (argc == 1) + return print_error(1, "No filename given"); + + if (!strcmp(argv[1], "-h") + || !strcmp(argv[1], "--help")) + return usage(); + else if (!strcmp(argv[1], "-v") + || !strcmp(argv[1], "--version")) + return version(); + else { strncpy(filename, argv[1], MAXPATH); filename[MAXPATH-1] = 0; diff --git a/poe.do b/poe.do @@ -1,6 +1,7 @@ +redo-ifchange config.def.h config.h for f in *.c; do echo $f + echo $f | sed -e's/\.c$/.o/g' done | xargs redo-ifchange -redo-ifchange poe.1.gz -gcc -g -Wall -std=c99 -o $3 po.o poe.o draw.o termbox.o utf8.o util.o +${POE_CC:-gcc} -g -Wall -std=c99 -o $3 po.o poe.o draw.o termbox.o utf8.o util.o diff --git a/version.h b/version.h @@ -0,0 +1,5 @@ +/* See the file LICENSE for copyright and license details. */ + +#define VERSION "0.1-alpha-1-g02e7b11" +#define DATE "16 Jun 2021" + diff --git a/version.h.in b/version.h.in @@ -0,0 +1,5 @@ +/* See the file LICENSE for copyright and license details. */ + +#define VERSION "%VERSION%" +#define DATE "%DATE%" +