Compare commits

...

1 Commits

Author SHA1 Message Date
Marcel Hollerbach 45c4f656e5 ty*: add unified --help / -h options to see a help page
This also adds documentation about the -h / --help options in the usages
2016-09-16 13:30:06 +02:00
7 changed files with 85 additions and 37 deletions

View File

@ -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++)

View File

@ -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];

View File

@ -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]);

View File

@ -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

View File

@ -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();

View File

@ -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];

View File

@ -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];