]> git.tdb.fi Git - pmount-gui.git/commitdiff
Add a help option
authorMikko Rasa <tdb@tdb.fi>
Sat, 15 Aug 2015 12:51:57 +0000 (15:51 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 15 Aug 2015 12:51:57 +0000 (15:51 +0300)
README.txt
main.c

index 2f6ebe60aa1f92a122c21dc418570700a09e0c44..9bdd562a61ea8ba3f4ec32adc158aaddc6deb640 100644 (file)
@@ -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.
 
 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 <command>
+    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.
 
 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 40b4483a87fb87810c332f4dd5228a554b737b5e..ae08cbb7cda87de794b03d673e40a6de691e721e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -789,6 +789,18 @@ gboolean key_press(GtkWidget *widget, GdkEvent *event, gpointer user_data)
        return FALSE;
 }
 
        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 <command>] [-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;
 int main(int argc, char **argv)
 {
        GtkWidget *window;
@@ -808,7 +820,7 @@ int main(int argc, char **argv)
 
        gtk_init(&argc, &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;
        {
        case 'v':
                ++verbosity;
@@ -819,6 +831,9 @@ int main(int argc, char **argv)
        case 'r':
                post_mount_command = optarg;
                break;
        case 'r':
                post_mount_command = optarg;
                break;
+       case 'h':
+               show_help();
+               return 0;
        }
 
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        }
 
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);