From 067f512e9469614d0536d2ac964365bd19c6fa4b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 21 Feb 2009 16:15:22 -0400 Subject: The --help (-h, -H) options now visit the man page --- src/global.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/global.cc') 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::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++) { -- cgit v1.2.3