Skip to content

Commit 2f27c1d

Browse files
Add synopsis and generate usage print from README
1 parent 871981b commit 2f27c1d

File tree

5 files changed

+55
-39
lines changed

5 files changed

+55
-39
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@
4343

4444
# ilclient
4545
/libs
46+
47+
# generated header
48+
help.h

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ CFLAGS+=-DVERSION=${BUILDVERSION} -DLCURL_NAME=$(LIBCURL_NAME)
99

1010
include Makefile.include
1111

12-
$(BIN): $(OBJS)
12+
$(BIN): help.h $(OBJS)
1313
$(CC) -o $@ $(OBJS) $(LDFLAGS)
14+
15+
clean::
16+
@rm -f help.h
17+
18+
help.h: README.md
19+
echo -n "static void printUsage(){printf(\"" > help.h
20+
sed -n -e '/\#\# Synopsis/,/\#\# / p' README.md | sed -e '1d;$$d' | sed ':a;N;$$!ba;s/\n/\\n/g' | tr '\n' ' ' >> help.h
21+
echo "\\\\n\");}" >> help.h
1422

1523
ilclient:
1624
mkdir -p libs

Makefile.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ all: $(BIN) $(LIB)
1414
%.a: $(OBJS)
1515
$(AR) r $@ $^
1616

17-
clean:
17+
clean::
1818
for i in $(OBJS); do (if test -e "$$i"; then ( rm $$i ); fi ); done
1919
@rm -f $(BIN) $(LIB)
2020

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,46 @@ And install with:
1414

1515
sudo make install
1616

17+
## Synopsis
18+
19+
USAGE:
20+
21+
omxiv [OPTIONS] image1 [image2] ...
22+
omxiv [OPTIONS] directory
23+
24+
Without any input it will cycle through all
25+
supported images in the current directory.
26+
27+
OPTIONS:
28+
29+
-h --help Print this help
30+
-v --version Show version info
31+
-t n Time in s between 2 images in a slide show
32+
-b --blank Set background to black
33+
-T --transition type type: none(default), blend
34+
--duration n Transition duration in ms
35+
--win 'x1 y1 x2 y2' Position of image window
36+
--win x1,y1,x2,y2 Position of image window
37+
-m --mirror Mirror image
38+
-a --aspect type type: letterbox(default), fill, center
39+
-o --orientation n Orientation of the image (0, 90, 180, 270)
40+
-l --layer n Render layer number
41+
-d --display n Display number
42+
-i --info Print some additional infos
43+
-k --no-keys Disable keyboard input
44+
-s --soft Force software decoding
45+
--ignore-exif Ignore exif orientation
46+
47+
KEY CONFIGURATION:
48+
49+
ESC, q : Quit
50+
LEFT : Previous image
51+
RIGHT : Next image
52+
UP : Rotate right
53+
DOWN : Rotate left
54+
m : Mirror image
55+
p : Pause slide show
56+
1757
## Supported images
1858

1959
* **JPEGs**

omxiv.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "omx_image.h"
1616
#include "soft_image.h"
1717
#include "bcm_host.h"
18+
#include "help.h"
1819

1920
#ifndef VERSION
2021
#define VERSION "UNKNOWN"
@@ -133,42 +134,6 @@ static int getImageFilesInDir(char ***list, const char* path){
133134
return imageNum;
134135
}
135136

136-
137-
void printUsage(const char *progr){
138-
printf("\n");
139-
printf("USAGE: %s [OPTIONS] image1 [image2] ...\n", progr);
140-
printf(" %s [OPTIONS] directory\n\n", progr);
141-
printf(" Without any input it will cycle through all\n");
142-
printf(" supported images in the current directory.\n\n");
143-
printf("OPTIONS:\n\n");
144-
printf(" -h --help Print this help\n");
145-
printf(" -v --version Show version info\n");
146-
printf(" -t n Time in s between 2 images in a slide show\n");
147-
printf(" -b --blank Set background to black\n");
148-
printf(" -T --transition type type: none(default), blend\n");
149-
printf(" --duration n Transition duration in ms\n");
150-
printf(" --win 'x1 y1 x2 y2' Position of image window\n");
151-
printf(" --win x1,y1,x2,y2 Position of image window\n");
152-
printf(" -m --mirror Mirror image\n");
153-
printf(" -a --aspect type type: letterbox(default), fill, center\n");
154-
printf(" -o --orientation n Orientation of the image (0, 90, 180, 270)\n");
155-
printf(" -l --layer n Render layer number\n");
156-
printf(" -d --display n Display number\n");
157-
printf(" -i --info Print some additional infos\n");
158-
printf(" -k --no-keys Disable keyboard input\n");
159-
printf(" -s --soft Force software decoding\n");
160-
printf(" --ignore-exif Ignore exif orientation\n\n");
161-
printf("KEY CONFIGURATION:\n\n");
162-
printf(" ESC, q : Quit\n");
163-
printf(" LEFT : Previous image\n");
164-
printf(" RIGHT : Next image\n");
165-
printf(" UP : Rotate right\n");
166-
printf(" DOWN : Rotate left\n");
167-
printf(" m : Mirror image\n");
168-
printf(" p : Pause slide show\n");
169-
printf("\n");
170-
}
171-
172137
// http://stackoverflow.com/a/912796
173138
static char getch(const int timeout) {
174139
char buf = 0;
@@ -417,7 +382,7 @@ int main(int argc, char *argv[]){
417382

418383
switch(opt){
419384
case 'h':
420-
printUsage(argv[0]);
385+
printUsage();
421386
return 0;
422387
case 'v':
423388
printVersion();

0 commit comments

Comments
 (0)