diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-21 16:15:22 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-21 16:24:10 -0400 |
commit | 067f512e9469614d0536d2ac964365bd19c6fa4b (patch) | |
tree | 17fd1f405ca046833ec671a340c33971ddfe7284 /src/global.cc | |
parent | 37097e600819a74da49a61bd1b9ea54c1ec53092 (diff) | |
download | fork-ledger-067f512e9469614d0536d2ac964365bd19c6fa4b.tar.gz fork-ledger-067f512e9469614d0536d2ac964365bd19c6fa4b.tar.bz2 fork-ledger-067f512e9469614d0536d2ac964365bd19c6fa4b.zip |
The --help (-h, -H) options now visit the man page
Diffstat (limited to 'src/global.cc')
-rw-r--r-- | src/global.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/global.cc b/src/global.cc index 26fa494f..e5972efd 100644 --- a/src/global.cc +++ b/src/global.cc @@ -239,6 +239,15 @@ option_t<global_scope_t> * global_scope_t::lookup_option(const char * p) case 'd': OPT(debug_); break; + case 'f': + OPT(full_help); + break; + case 'h': + OPT_(help); + else OPT(help_calc); + else OPT(help_comm); + else OPT(help_disp); + break; case 'i': OPT(init_file_); break; @@ -455,6 +464,25 @@ void global_scope_t::normalize_report_options(const string& verb) } } +void global_scope_t::visit_man_page() const +{ + int pid = fork(); + if (pid < 0) { + throw std::logic_error("Failed to fork child process"); + } + else if (pid == 0) { // child + execlp("man", "man", "1", "ledger", (char *)0); + + // We should never, ever reach here + perror("execlp: man"); + exit(1); + } + + int status = -1; + wait(&status); + exit(0); // parent +} + void handle_debug_options(int argc, char * argv[]) { for (int i = 1; i < argc; i++) { |