Permalink
Browse files

--help, --version

  • Loading branch information...
1 parent 0e75f4b commit d891a4f7954e014bcd587eb73f0d77dc158640f7 @mikejs committed Sep 27, 2009
Showing with 41 additions and 2 deletions.
  1. +3 −1 main.cpp
  2. +34 −1 options.cpp
  3. +4 −0 options.h
View
4 main.cpp
@@ -36,7 +36,9 @@ int main(int argc, char *argv[])
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
memset(&gridfs_options, 0, sizeof(struct gridfs_options));
- if(fuse_opt_parse(&args, &gridfs_options, gridfs_opts, NULL) == -1) {
+ if(fuse_opt_parse(&args, &gridfs_options, gridfs_opts,
+ gridfs_opt_proc) == -1)
+ {
return -1;
}
View
35 options.cpp
@@ -16,16 +16,49 @@
*/
#include "options.h"
+#include <iostream>
+
+using namespace std;
struct gridfs_options gridfs_options;
struct fuse_opt gridfs_opts[] =
{
GRIDFS_OPT_KEY("--host=%s", host, 0),
GRIDFS_OPT_KEY("--db=%s", db, 0),
- FUSE_OPT_KEY("-V", KEY_VERSION),
+ FUSE_OPT_KEY("-v", KEY_VERSION),
FUSE_OPT_KEY("--version", KEY_VERSION),
FUSE_OPT_KEY("-h", KEY_HELP),
FUSE_OPT_KEY("--help", KEY_HELP),
NULL
};
+
+int gridfs_opt_proc(void* data, const char* arg, int key,
+ struct fuse_args* outargs)
+{
+ if(key == KEY_HELP) {
+ print_help();
+ return -1;
+ }
+
+ if(key == KEY_VERSION) {
+ cout << "gridfs-fuse version 0.1" << endl;
+ return -1;
+ }
+
+ return 1;
+}
+
+void print_help()
+{
+ cout << "usage: ./mount_gridfs [options] mountpoint" << endl;
+ cout << endl << "general options:" << endl;
+ cout << "\t--db=[dbname]\t\twhich mongo database to use" << endl;
+ cout << "\t--host=[hostname]\thostname of your mongodb server" << endl;
+ cout << "\t-h, --help\t\tprint help" << endl;
+ cout << "\t-v, --version\t\tprint version" << endl;
+ cout << endl << "FUSE options: " << endl;
+ cout << "\t-d, -o debug\t\tenable debug output (implies -f)" << endl;
+ cout << "\t-f\t\t\tforeground operation" << endl;
+ cout << "\t-s\t\t\tdisable multi-threaded operation" << endl;
+}
View
4 options.h
@@ -37,4 +37,8 @@ enum {
extern struct fuse_opt gridfs_opts[];
+int gridfs_opt_proc(void* data, const char* arg, int key,
+ struct fuse_args* outargs);
+
+void print_help();
#endif

0 comments on commit d891a4f

Please sign in to comment.