+1 ;)

On Friday 16 September 2016  04:44, Marcel Hollerbach wrote :
> bu5hm4n pushed a commit to branch master.
> 
> http://git.enlightenment.org/apps/terminology.git/commit/?id=b038ed7ff6fa112fe8b8742b101445502ae89380
> 
> commit b038ed7ff6fa112fe8b8742b101445502ae89380
> Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
> Date:   Thu Sep 1 15:14:39 2016 +0200
> 
>     ty*: add unified --help / -h options to see a help page
>     
>     This also adds documentation about the -h / --help options in the usages
> ---
>  src/bin/tyalpha.c  | 18 +++++++++++++-----
>  src/bin/tybg.c     | 21 +++++++++++----------
>  src/bin/tycat.c    |  7 ++++---
>  src/bin/tycommon.h | 17 +++++++++++++++++
>  src/bin/tyls.c     | 25 ++++++++++++++-----------
>  src/bin/typop.c    | 17 +++++++++++++----
>  src/bin/tyq.c      | 17 +++++++++++++----
>  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 @@
>  #include <Eina.h>
>  #include "tycommon.h"
>  
> +static void
> +print_usage(const char *argv0)
> +{
> +   printf("Usage: %s "HELP_ARGUMENT_SHORT"[-p] on|off|<opacity level>\n"
> +          "  Change the terminal transparency on or off\n"
> +          "  -p  Make change permanent (stored in config)\n"
> +          HELP_ARGUMENT_DOC"\n"
> +          "\n",
> +          argv0);
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
>     int i, perm = 0;
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>  
>     if (argc <= 1)
>       {
> -        printf("Usage: %s [-p] on|off|<opacity level>\n"
> -               "  Change the terminal transparency on or off\n"
> -               "  -p  Make change permanent (stored in config)\n"
> -               "\n",
> -               argv[0]);
> +        print_usage(argv[0]);
>          return 0;
>       }
>     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 @@
>  #include <Eina.h>
>  #include "tycommon.h"
>  
> +static void
> +print_usage(const char *argv0)
> +{
> +   printf("Usage: %s "HELP_ARGUMENT_SHORT" [-p] [FILE1 FILE2 ...]\n"
> +          "  Change the terminal background to the given file/uri\n"
> +          "  -p  Make change permanent (stored in config)\n"
> +          HELP_ARGUMENT_DOC"\n"
> +          "\n",
> +          argv0);
> +}
>  
>  int
>  main(int argc, char **argv)
> @@ -14,17 +24,8 @@ main(int argc, char **argv)
>     int i, perm = 0;
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>  
> -   if (argc > 1 &&
> -       (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
> -     {
> -        printf("Usage: %s [-p] [FILE1 FILE2 ...]\n"
> -               "  Change the terminal background to the given file/uri\n"
> -               "  -p  Make change permanent (stored in config)\n"
> -               "\n",
> -               argv[0]);
> -        return 0;
> -     }
>     if (argc <= 1)
>       {
>          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)
>  static void
>  print_usage(const char *argv0)
>  {
> -   printf("Usage: %s [-s|-f|-c] [-g <width>x<height>] FILE1 [FILE2 ...]\n"
> +   printf("Usage: %s "HELP_ARGUMENT_SHORT" [-s|-f|-c] [-g <width>x<height>] 
> FILE1 [FILE2 ...]\n"
>            "\n"
>            "  -s  Stretch file to fill nearest character cell size\n"
>            "  -f  Fill file to totally cover character cells with no gaps\n"
>            "  -c  Center file in nearest character cells but only scale down 
> (default)\n"
> -          "  -g <width>x<height>  Set maximum geometry for the image (cell 
> count)\n",
> +          "  -g <width>x<height>  Set maximum geometry for the image (cell 
> count)\n"
> +          HELP_ARGUMENT_DOC"\n",
>           argv0);
>  }
>  
> @@ -311,7 +312,7 @@ main(int argc, char **argv)
>     Eina_List *file_q = NULL;
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> -
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>     if (argc <= 1)
>       {
>          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);
>      }                                                                      \
>    while (0)
>  
> +#define HELP_ARGUMENT_DOC  "  -h or --help Display this help."
> +#define HELP_ARGUMENT_SHORT "[-h]"
> +
> +#define ARGUMENT_ENTRY_CHECK(argc, argv, help_func) \
> +    do \
> +      { \
> +         int i = 0; \
> +         for(i = 0; i < argc; i++) \
> +           { \
> +             if (!strcmp(argv[i], "--help") || !strcmp(argv[i],"-h")) \
> +               { \
> +                  help_func(argv[0]); \
> +                  return EXIT_SUCCESS; \
> +               } \
> +         } \
> +      } \
> +    while(0)
>  
>  #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)
>     EINA_LIST_FREE(files, s) free(s);
>  }
>  
> +static void
> +print_usage(const char *argv0)
> +{
> +   printf("Usage: %s "HELP_ARGUMENT_SHORT" [-a] [-s|-m] FILE1 [FILE2 ...]\n"
> +          "\n"
> +          "  -a  Show hidden files\n"
> +          "  -s  Small list mode\n"
> +          "  -m  Medium list mode\n"
> +          HELP_ARGUMENT_DOC"\n",
> +          /*"  -l  Large list mode\n", Enable again once we support it */
> +          argv0);
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
> @@ -728,18 +741,8 @@ main(int argc, char **argv)
>     Tyls_Options options = {SMALL, EINA_FALSE};
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>  
> -   if ((argc == 2) && (!strcmp(argv[1], "-h")))
> -     {
> -        printf("Usage: %s [-a] [-s|-m] FILE1 [FILE2 ...]\n"
> -               "\n"
> -               "  -a  Show hidden files\n"
> -               "  -s  Small list mode\n"
> -               "  -m  Medium list mode\n",
> -               /*"  -l  Large list mode\n", Enable again once we support it 
> */
> -              argv[0]);
> -        return 0;
> -     }
>     eina_init();
>  #if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
>     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 @@
>  #include <Eina.h>
>  #include "tycommon.h"
>  
> +static void
> +print_usage(const char *argv0)
> +{
> +   printf("Usage: %s"HELP_ARGUMENT_SHORT" FILE1 [FILE2 ...]\n"
> +          "  Pop up a given media file/uri right now\n"
> +          HELP_ARGUMENT_DOC"\n"
> +          "\n",
> +          argv0);
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
>     int i;
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>  
>     if (argc <= 1)
>       {
> -        printf("Usage: %s FILE1 [FILE2 ...]\n"
> -               "  Pop up a given media file/uri right now\n"
> -               "\n",
> -               argv[0]);
> +        print_usage(argv[0]);
>          return 0;
>       }
> +
>     for (i = 1; i < argc; i++)
>       {
>          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 @@
>  #include <Eina.h>
>  #include "tycommon.h"
>  
> +static void
> +print_usage(const char* argv0)
> +{
> +   printf("Usage: %s FILE1 [FILE2 ...]\n"
> +         "  Queue a given media file/uri to the popped up\n"
> +         HELP_ARGUMENT_DOC"\n"
> +         "\n",
> +         argv0);
> +}
> +
>  int
>  main(int argc, char **argv)
>  {
>     int i;
>  
>     ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
> +   ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
>  
>     if (argc <= 1)
>       {
> -        printf("Usage: %s FILE1 [FILE2 ...]\n"
> -               "  Queue a given media file/uri to the popped up\n"
> -               "\n",
> -               argv[0]);
> +        print_usage(argv[0]);
>          return 0;
>       }
> +
>     for (i = 1; i < argc; i++)
>       {
>          char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];
> 
> -- 
> 
> 
--- Hell'O from Yverdoom

Jérémy (jeyzu)

------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to