diff options
Diffstat (limited to 'src/option.h')
-rw-r--r-- | src/option.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/option.h b/src/option.h index 7deb5f58..b201cb72 100644 --- a/src/option.h +++ b/src/option.h @@ -90,10 +90,17 @@ public: string desc() const { std::ostringstream out; + out << "--"; + for (const char * p = name; *p; p++) { + if (*p == '_') { + if (*(p + 1)) + out << '-'; + } else { + out << *p; + } + } if (ch) - out << "--" << name << " (-" << ch << ")"; - else - out << "--" << name; + out << " (-" << ch << ")"; return out.str(); } @@ -136,10 +143,13 @@ public: virtual void handler_thunk(call_scope_t&) {} virtual void handler(call_scope_t& args) { - if (wants_arg) + if (wants_arg) { + if (args.empty()) + throw_(std::runtime_error, "No argument provided for " << desc()); on(args[0]); - else + } else { on(); + } handler_thunk(args); } |