Use DLOG/ELOG-macros, provide --verbose-option

This commit is contained in:
Axel Wagner
2010-09-17 06:49:28 +02:00
parent ca1a295714
commit 920721bb93
8 changed files with 83 additions and 66 deletions

View File

@ -25,12 +25,12 @@
char *expand_path(char *path) {
static glob_t globbuf;
if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) {
printf("glob() failed");
ELOG("glob() failed\n");
exit(EXIT_FAILURE);
}
char *result = strdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
if (result == NULL) {
printf("malloc() failed");
ELOG("malloc() failed\n");
exit(EXIT_FAILURE);
}
globfree(&globbuf);
@ -38,13 +38,14 @@ char *expand_path(char *path) {
}
void print_usage(char *elf_name) {
printf("Usage: %s [-s sock_path] [-c command] [-m] [-f font] [-h]\n", elf_name);
printf("Usage: %s [-s sock_path] [-c command] [-m] [-f font] [-V] [-h]\n", elf_name);
printf("-s <sock_path>\tConnect to i3 via <sock_path>\n");
printf("-c <command>\tExecute <command> to get stdin\n");
printf("-m\t\tHide the bars, when mod4 is not pressed.\n");
printf("\t\tIf -c is specified, the childprocess is sent a SIGSTOP on hiding,\n");
printf("\t\tand a SIGCONT on unhiding of the bars\n");
printf("-f <font>\tUse X-Core-Font <font> for display\n");
printf("-V\t\tBe (very) verbose with the debug-output\n");
printf("-h\t\tDisplay this help-message and exit\n");
}
@ -66,10 +67,11 @@ int main(int argc, char **argv) {
{ "font", required_argument, 0, 'f' },
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "verbose", no_argument, 0, 'V' },
{ NULL, 0, 0, 0}
};
while ((opt = getopt_long(argc, argv, "s:c:mf:hv", long_opt, &option_index)) != -1) {
while ((opt = getopt_long(argc, argv, "s:c:mf:hvV", long_opt, &option_index)) != -1) {
switch (opt) {
case 's':
socket_path = expand_path(optarg);
@ -87,6 +89,9 @@ int main(int argc, char **argv) {
printf("i3bar version " I3BAR_VERSION " © 2010 Axel Wagner and contributors\n");
exit(EXIT_SUCCESS);
break;
case 'V':
config.verbose = 1;
break;
default:
print_usage(argv[0]);
exit(EXIT_SUCCESS);
@ -102,7 +107,7 @@ int main(int argc, char **argv) {
}
if (socket_path == NULL) {
printf("No Socket Path Specified, default to %s\n", i3_default_sock_path);
ELOG("No Socket Path Specified, default to %s\n", i3_default_sock_path);
socket_path = expand_path(i3_default_sock_path);
}