cho2txt

Extract lyrics from chordpro files
git clone git://git.relim.de/cho2txt.git
Log | Files | Refs | README | LICENSE

commit ca0bbeaf1daae12da3935bac24ee811d514adf76
parent a103eec849a16123090606f52f3a718e3b3829cd
Author: nibo <kroekerrobin@gmail.com>
Date:   Mon, 10 Jul 2023 18:59:02 +0200

Add -v, --version argument

Diffstat:
Mcho2txt.1 | 8++++++++
Mcho2txt.c | 10++++++++--
Mcho2txt.h | 2++
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/cho2txt.1 b/cho2txt.1 @@ -5,6 +5,8 @@ cho2txt - Extract lyrics from chordpro files .B cho2txt [-t] [-d] +[-h] +[-v] [FILE]... .SH DESCRIPTION .PP @@ -20,6 +22,12 @@ Print the title of the song, e.g. 'Love Me Tender'. .TP \fB\,-d\/\fR, \fB\,--directive\/\fR Print the title of the song as chordpro directive, e.g. '{title: Love Me Tender}' +.TP +\fB\,-h\/\fR, \fB\,--help\/\fR +Print help information. +.TP +\fB\,-v\/\fR, \fB\,--version\/\fR +Print program version to stdout. .SH EXAMPLES .sp .RS 4 diff --git a/cho2txt.c b/cho2txt.c @@ -12,7 +12,9 @@ void printHelp() static const char help[] = "Usage: cho2txt [-t] [-d] [FILE]...\n" "Extract lyrics from chordpro files.\n\n" " -t, --title\t\tPrint title\n" - " -d, --directive\tPrint title as chordpro directive\n"; + " -d, --directive\tPrint title as chordpro directive\n" + " -h, --help\t\tPrints help information\n" + " -v, --version\t\tPrint program version to stdout\n"; printf("%s", help); } @@ -225,9 +227,10 @@ int main(int argc, char *argv[]) { "title", no_argument, 0, 't' }, { "directive", no_argument, 0, 'd' }, { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; - while ((o = getopt_long(argc, argv, "td", long_options, &optionIndex)) != -1) { + while ((o = getopt_long(argc, argv, "tdhv", long_options, &optionIndex)) != -1) { switch(o) { case 't': printTitle = PRINT_TITLE; @@ -238,6 +241,9 @@ int main(int argc, char *argv[]) case 'h': printHelp(); return 0; + case 'v': + printf("%.1f\n", VERSION); + return 0; } } if (argc == optind) diff --git a/cho2txt.h b/cho2txt.h @@ -1,3 +1,5 @@ +#define VERSION 1.0 + enum print { PRINT_NO,