Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Add synopsis and generate usage print from README
Browse files Browse the repository at this point in the history
  • Loading branch information
HaarigerHarald committed Nov 25, 2018
1 parent 871981b commit 2f27c1d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -43,3 +43,6 @@

# ilclient
/libs

# generated header
help.h
10 changes: 9 additions & 1 deletion Makefile
Expand Up @@ -9,8 +9,16 @@ CFLAGS+=-DVERSION=${BUILDVERSION} -DLCURL_NAME=$(LIBCURL_NAME)

include Makefile.include

$(BIN): $(OBJS)
$(BIN): help.h $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS)

clean::
@rm -f help.h

help.h: README.md
echo -n "static void printUsage(){printf(\"" > help.h
sed -n -e '/\#\# Synopsis/,/\#\# / p' README.md | sed -e '1d;$$d' | sed ':a;N;$$!ba;s/\n/\\n/g' | tr '\n' ' ' >> help.h
echo "\\\\n\");}" >> help.h

ilclient:
mkdir -p libs
Expand Down
2 changes: 1 addition & 1 deletion Makefile.include
Expand Up @@ -14,7 +14,7 @@ all: $(BIN) $(LIB)
%.a: $(OBJS)
$(AR) r $@ $^

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

40 changes: 40 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,46 @@ And install with:

sudo make install

## Synopsis

USAGE:

omxiv [OPTIONS] image1 [image2] ...
omxiv [OPTIONS] directory

Without any input it will cycle through all
supported images in the current directory.

OPTIONS:

-h --help Print this help
-v --version Show version info
-t n Time in s between 2 images in a slide show
-b --blank Set background to black
-T --transition type type: none(default), blend
--duration n Transition duration in ms
--win 'x1 y1 x2 y2' Position of image window
--win x1,y1,x2,y2 Position of image window
-m --mirror Mirror image
-a --aspect type type: letterbox(default), fill, center
-o --orientation n Orientation of the image (0, 90, 180, 270)
-l --layer n Render layer number
-d --display n Display number
-i --info Print some additional infos
-k --no-keys Disable keyboard input
-s --soft Force software decoding
--ignore-exif Ignore exif orientation

KEY CONFIGURATION:

ESC, q : Quit
LEFT : Previous image
RIGHT : Next image
UP : Rotate right
DOWN : Rotate left
m : Mirror image
p : Pause slide show

## Supported images

* **JPEGs**
Expand Down
39 changes: 2 additions & 37 deletions omxiv.c
Expand Up @@ -15,6 +15,7 @@
#include "omx_image.h"
#include "soft_image.h"
#include "bcm_host.h"
#include "help.h"

#ifndef VERSION
#define VERSION "UNKNOWN"
Expand Down Expand Up @@ -133,42 +134,6 @@ static int getImageFilesInDir(char ***list, const char* path){
return imageNum;
}


void printUsage(const char *progr){
printf("\n");
printf("USAGE: %s [OPTIONS] image1 [image2] ...\n", progr);
printf(" %s [OPTIONS] directory\n\n", progr);
printf(" Without any input it will cycle through all\n");
printf(" supported images in the current directory.\n\n");
printf("OPTIONS:\n\n");
printf(" -h --help Print this help\n");
printf(" -v --version Show version info\n");
printf(" -t n Time in s between 2 images in a slide show\n");
printf(" -b --blank Set background to black\n");
printf(" -T --transition type type: none(default), blend\n");
printf(" --duration n Transition duration in ms\n");
printf(" --win 'x1 y1 x2 y2' Position of image window\n");
printf(" --win x1,y1,x2,y2 Position of image window\n");
printf(" -m --mirror Mirror image\n");
printf(" -a --aspect type type: letterbox(default), fill, center\n");
printf(" -o --orientation n Orientation of the image (0, 90, 180, 270)\n");
printf(" -l --layer n Render layer number\n");
printf(" -d --display n Display number\n");
printf(" -i --info Print some additional infos\n");
printf(" -k --no-keys Disable keyboard input\n");
printf(" -s --soft Force software decoding\n");
printf(" --ignore-exif Ignore exif orientation\n\n");
printf("KEY CONFIGURATION:\n\n");
printf(" ESC, q : Quit\n");
printf(" LEFT : Previous image\n");
printf(" RIGHT : Next image\n");
printf(" UP : Rotate right\n");
printf(" DOWN : Rotate left\n");
printf(" m : Mirror image\n");
printf(" p : Pause slide show\n");
printf("\n");
}

// http://stackoverflow.com/a/912796
static char getch(const int timeout) {
char buf = 0;
Expand Down Expand Up @@ -417,7 +382,7 @@ int main(int argc, char *argv[]){

switch(opt){
case 'h':
printUsage(argv[0]);
printUsage();
return 0;
case 'v':
printVersion();
Expand Down

0 comments on commit 2f27c1d

Please sign in to comment.