summaryrefslogtreecommitdiffstats
path: root/src/c_mpdview.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_mpdview.c')
-rw-r--r--src/c_mpdview.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 46e11ed..7089d36 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -66,7 +66,7 @@
#include "c_mpdview.h"
static struct mpdview_s *
-c_create_view(void)
+c_create_view(bool_t verbose)
{
struct mpdview_s* view;
@@ -78,6 +78,7 @@ c_create_view(void)
view->status = NULL;
view->song = NULL;
view->state = MPD_STATE_UNKNOWN;
+ view->verbose = verbose;
return (view);
}
@@ -178,15 +179,32 @@ c_get_current_dir(struct mpdview_s* v)
int
main
(int argc,
- const char* argv[],
- const char* envp[])
+ char* const argv[])
{
struct mpdview_s* view;
+ bool_t verbose;
+ char c;
- (void)argc;
- (void)argv;
- (void)envp;
- view = c_create_view();
+ verbose = FALSE;
+ while ((c = getopt(argc, argv, OPTSTRING)) != -1) {
+ if (c == 'h') {
+ /* TODO: usage(); */
+ dprintf(STDOUT_FILENO, "help\n");
+ return (EXIT_SUCCESS);
+ }
+ else if (c == 'v') {
+ verbose = TRUE;
+ }
+ else if (c == 'V') {
+ dprintf(STDOUT_FILENO, "%s %s\n", PROGNAME, VERSION);
+ return (EXIT_SUCCESS);
+ }
+ else if (c == '?') {
+ /* TODO: usage(); */
+ return (EXIT_FAILURE);
+ }
+ }
+ view = c_create_view(verbose);
if (view == NULL) {
return (EXIT_FAILURE);
}
@@ -205,7 +223,9 @@ main
return (EXIT_FAILURE);
}
c_get_current_dir(view);
- dprintf(STDOUT_FILENO, "%s\n", view->current_dir);
+ if (view->verbose == TRUE) {
+ dprintf(STDOUT_FILENO, "%s\n", view->current_dir);
+ }
}
c_destroy_mpdview(&view);
return (EXIT_SUCCESS);