From a76de4d866743180e75f51088dd6d1407dcded9f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 15 Aug 2015 15:51:57 +0300 Subject: [PATCH] Add a help option --- README.txt | 17 ++++++++++++++--- main.c | 17 ++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.txt b/README.txt index 2f6ebe6..9bdd562 100644 --- a/README.txt +++ b/README.txt @@ -5,10 +5,21 @@ one to mount. Default selection is the device which was connected to the system last, making it easy to quickly mount the USB memory stick you just plugged in. -In addition, there are two command-line switches: +In addition, there are some command-line switches: - -u Unmount a device. - -v Increases verbosity. Useful if pmount-gui is misbehaving. + -u + Unmount a device instead of mounting. + + -v + Increases verbosity. Useful if pmount-gui is misbehaving. + + -r + Runs a command after mounting, for example a terminal emulator or a file + manager. The command is run without arguments in the directory where the + device was mounted. + + -h + Displays a summary of options. Suggested usage pattern is to bind pmount-gui to a shortcut key in your window manager to provide quick access. diff --git a/main.c b/main.c index 40b4483..ae08cbb 100644 --- a/main.c +++ b/main.c @@ -789,6 +789,18 @@ gboolean key_press(GtkWidget *widget, GdkEvent *event, gpointer user_data) return FALSE; } +void show_help(void) +{ + printf("pmount-gui\n" + "Copyright (c) 2011-2015 Mikko Rasa, Mikkosoft Productions\n\n" + "Usage: pmount-gui [-v] [-u] [-r ] [-h]\n\n" + "Options:\n" + " -v Increase verbosity\n" + " -u Unmount a device (default is mount)\n" + " -r Run a command after mounting\n" + " -h Display this help\n"); +} + int main(int argc, char **argv) { GtkWidget *window; @@ -808,7 +820,7 @@ int main(int argc, char **argv) gtk_init(&argc, &argv); - while((opt = getopt(argc, argv, "vur:"))!=-1) switch(opt) + while((opt = getopt(argc, argv, "vur:h"))!=-1) switch(opt) { case 'v': ++verbosity; @@ -819,6 +831,9 @@ int main(int argc, char **argv) case 'r': post_mount_command = optarg; break; + case 'h': + show_help(); + return 0; } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); -- 2.45.2