summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-09-01 15:14:39 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-09-16 13:30:06 +0200
commit45c4f656e5730be1a2e1f55499b29994b8e985cf (patch)
tree2698e3dd5e58768c8d9e2a4071573ee89ef56901
parentdfe08f0ce0b2980dcceef84087aca5b8d18d0fb4 (diff)
ty*: add unified --help / -h options to see a help pagedevs/bu5hm4n/next
This also adds documentation about the -h / --help options in the usages
-rw-r--r--src/bin/tyalpha.c18
-rw-r--r--src/bin/tybg.c21
-rw-r--r--src/bin/tycat.c7
-rw-r--r--src/bin/tycommon.h17
-rw-r--r--src/bin/tyls.c25
-rw-r--r--src/bin/typop.c17
-rw-r--r--src/bin/tyq.c17
7 files changed, 85 insertions, 37 deletions
diff --git a/src/bin/tyalpha.c b/src/bin/tyalpha.c
index 7b55b7a..e0b2646 100644
--- a/src/bin/tyalpha.c
+++ b/src/bin/tyalpha.c
@@ -7,20 +7,28 @@
7#include <Eina.h> 7#include <Eina.h>
8#include "tycommon.h" 8#include "tycommon.h"
9 9
10static void
11print_usage(const char *argv0)
12{
13 printf("Usage: %s "HELP_ARGUMENT_SHORT"[-p] on|off|<opacity level>\n"
14 " Change the terminal transparency on or off\n"
15 " -p Make change permanent (stored in config)\n"
16 HELP_ARGUMENT_DOC"\n"
17 "\n",
18 argv0);
19}
20
10int 21int
11main(int argc, char **argv) 22main(int argc, char **argv)
12{ 23{
13 int i, perm = 0; 24 int i, perm = 0;
14 25
15 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 26 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
27 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
16 28
17 if (argc <= 1) 29 if (argc <= 1)
18 { 30 {
19 printf("Usage: %s [-p] on|off|<opacity level>\n" 31 print_usage(argv[0]);
20 " Change the terminal transparency on or off\n"
21 " -p Make change permanent (stored in config)\n"
22 "\n",
23 argv[0]);
24 return 0; 32 return 0;
25 } 33 }
26 for (i = 1; i < argc; i++) 34 for (i = 1; i < argc; i++)
diff --git a/src/bin/tybg.c b/src/bin/tybg.c
index cc3df43..11969cc 100644
--- a/src/bin/tybg.c
+++ b/src/bin/tybg.c
@@ -7,6 +7,16 @@
7#include <Eina.h> 7#include <Eina.h>
8#include "tycommon.h" 8#include "tycommon.h"
9 9
10static void
11print_usage(const char *argv0)
12{
13 printf("Usage: %s "HELP_ARGUMENT_SHORT" [-p] [FILE1 FILE2 ...]\n"
14 " Change the terminal background to the given file/uri\n"
15 " -p Make change permanent (stored in config)\n"
16 HELP_ARGUMENT_DOC"\n"
17 "\n",
18 argv0);
19}
10 20
11int 21int
12main(int argc, char **argv) 22main(int argc, char **argv)
@@ -14,17 +24,8 @@ main(int argc, char **argv)
14 int i, perm = 0; 24 int i, perm = 0;
15 25
16 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 26 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
27 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
17 28
18 if (argc > 1 &&
19 (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
20 {
21 printf("Usage: %s [-p] [FILE1 FILE2 ...]\n"
22 " Change the terminal background to the given file/uri\n"
23 " -p Make change permanent (stored in config)\n"
24 "\n",
25 argv[0]);
26 return 0;
27 }
28 if (argc <= 1) 29 if (argc <= 1)
29 { 30 {
30 char tbuf[32]; 31 char tbuf[32];
diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index 709640d..c90dec5 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -120,12 +120,13 @@ prnt(const char *path, int w, int h, int mode)
120static void 120static void
121print_usage(const char *argv0) 121print_usage(const char *argv0)
122{ 122{
123 printf("Usage: %s [-s|-f|-c] [-g <width>x<height>] FILE1 [FILE2 ...]\n" 123 printf("Usage: %s "HELP_ARGUMENT_SHORT" [-s|-f|-c] [-g <width>x<height>] FILE1 [FILE2 ...]\n"
124 "\n" 124 "\n"
125 " -s Stretch file to fill nearest character cell size\n" 125 " -s Stretch file to fill nearest character cell size\n"
126 " -f Fill file to totally cover character cells with no gaps\n" 126 " -f Fill file to totally cover character cells with no gaps\n"
127 " -c Center file in nearest character cells but only scale down (default)\n" 127 " -c Center file in nearest character cells but only scale down (default)\n"
128 " -g <width>x<height> Set maximum geometry for the image (cell count)\n", 128 " -g <width>x<height> Set maximum geometry for the image (cell count)\n"
129 HELP_ARGUMENT_DOC"\n",
129 argv0); 130 argv0);
130} 131}
131 132
@@ -311,7 +312,7 @@ main(int argc, char **argv)
311 Eina_List *file_q = NULL; 312 Eina_List *file_q = NULL;
312 313
313 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 314 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
314 315 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
315 if (argc <= 1) 316 if (argc <= 1)
316 { 317 {
317 print_usage(argv[0]); 318 print_usage(argv[0]);
diff --git a/src/bin/tycommon.h b/src/bin/tycommon.h
index f29b247..da7af40 100644
--- a/src/bin/tycommon.h
+++ b/src/bin/tycommon.h
@@ -14,5 +14,22 @@ Eina_Bool is_running_in_terminology(void);
14 } \ 14 } \
15 while (0) 15 while (0)
16 16
17#define HELP_ARGUMENT_DOC " -h or --help Display this help."
18#define HELP_ARGUMENT_SHORT "[-h]"
19
20#define ARGUMENT_ENTRY_CHECK(argc, argv, help_func) \
21 do \
22 { \
23 int i = 0; \
24 for(i = 0; i < argc; i++) \
25 { \
26 if (!strcmp(argv[i], "--help") || !strcmp(argv[i],"-h")) \
27 { \
28 help_func(argv[0]); \
29 return EXIT_SUCCESS; \
30 } \
31 } \
32 } \
33 while(0)
17 34
18#endif 35#endif
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index 9bdd305..340101e 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -719,6 +719,19 @@ list_dir(const char *dir, Tyls_Options *options)
719 EINA_LIST_FREE(files, s) free(s); 719 EINA_LIST_FREE(files, s) free(s);
720} 720}
721 721
722static void
723print_usage(const char *argv0)
724{
725 printf("Usage: %s "HELP_ARGUMENT_SHORT" [-a] [-s|-m] FILE1 [FILE2 ...]\n"
726 "\n"
727 " -a Show hidden files\n"
728 " -s Small list mode\n"
729 " -m Medium list mode\n"
730 HELP_ARGUMENT_DOC"\n",
731 /*" -l Large list mode\n", Enable again once we support it */
732 argv0);
733}
734
722int 735int
723main(int argc, char **argv) 736main(int argc, char **argv)
724{ 737{
@@ -728,18 +741,8 @@ main(int argc, char **argv)
728 Tyls_Options options = {SMALL, EINA_FALSE}; 741 Tyls_Options options = {SMALL, EINA_FALSE};
729 742
730 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 743 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
744 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
731 745
732 if ((argc == 2) && (!strcmp(argv[1], "-h")))
733 {
734 printf("Usage: %s [-a] [-s|-m] FILE1 [FILE2 ...]\n"
735 "\n"
736 " -a Show hidden files\n"
737 " -s Small list mode\n"
738 " -m Medium list mode\n",
739 /*" -l Large list mode\n", Enable again once we support it */
740 argv[0]);
741 return 0;
742 }
743 eina_init(); 746 eina_init();
744#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8) 747#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
745 ecore_app_no_system_modules(); 748 ecore_app_no_system_modules();
diff --git a/src/bin/typop.c b/src/bin/typop.c
index 569ade5..8f76e2d 100644
--- a/src/bin/typop.c
+++ b/src/bin/typop.c
@@ -7,21 +7,30 @@
7#include <Eina.h> 7#include <Eina.h>
8#include "tycommon.h" 8#include "tycommon.h"
9 9
10static void
11print_usage(const char *argv0)
12{
13 printf("Usage: %s"HELP_ARGUMENT_SHORT" FILE1 [FILE2 ...]\n"
14 " Pop up a given media file/uri right now\n"
15 HELP_ARGUMENT_DOC"\n"
16 "\n",
17 argv0);
18}
19
10int 20int
11main(int argc, char **argv) 21main(int argc, char **argv)
12{ 22{
13 int i; 23 int i;
14 24
15 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 25 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
26 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
16 27
17 if (argc <= 1) 28 if (argc <= 1)
18 { 29 {
19 printf("Usage: %s FILE1 [FILE2 ...]\n" 30 print_usage(argv[0]);
20 " Pop up a given media file/uri right now\n"
21 "\n",
22 argv[0]);
23 return 0; 31 return 0;
24 } 32 }
33
25 for (i = 1; i < argc; i++) 34 for (i = 1; i < argc; i++)
26 { 35 {
27 char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3]; 36 char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];
diff --git a/src/bin/tyq.c b/src/bin/tyq.c
index f78fcc0..2b6af4a 100644
--- a/src/bin/tyq.c
+++ b/src/bin/tyq.c
@@ -7,21 +7,30 @@
7#include <Eina.h> 7#include <Eina.h>
8#include "tycommon.h" 8#include "tycommon.h"
9 9
10static void
11print_usage(const char* argv0)
12{
13 printf("Usage: %s FILE1 [FILE2 ...]\n"
14 " Queue a given media file/uri to the popped up\n"
15 HELP_ARGUMENT_DOC"\n"
16 "\n",
17 argv0);
18}
19
10int 20int
11main(int argc, char **argv) 21main(int argc, char **argv)
12{ 22{
13 int i; 23 int i;
14 24
15 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1(); 25 ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
26 ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
16 27
17 if (argc <= 1) 28 if (argc <= 1)
18 { 29 {
19 printf("Usage: %s FILE1 [FILE2 ...]\n" 30 print_usage(argv[0]);
20 " Queue a given media file/uri to the popped up\n"
21 "\n",
22 argv[0]);
23 return 0; 31 return 0;
24 } 32 }
33
25 for (i = 1; i < argc; i++) 34 for (i = 1; i < argc; i++)
26 { 35 {
27 char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3]; 36 char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];