Changeset 10303


Ignore:
Timestamp:
Apr 7, 2011, 12:59:40 PM (9 years ago)
Author:
tbretz
Message:
Added some examples how a proper --help output should look to be properly converted by help2man.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/test3.cc

    r10230 r10303  
    4848}
    4949
     50/*
     51 Extract usage clause(s) [if any] for SYNOPSIS.
     52 Translators: "Usage" and "or" here are patterns (regular expressions) which
     53 are used to match the usage synopsis in program output.  An example from cp
     54 (GNU coreutils) which contains both strings:
     55  Usage: cp [OPTION]... [-T] SOURCE DEST
     56    or:  cp [OPTION]... SOURCE... DIRECTORY
     57    or:  cp [OPTION]... -t DIRECTORY SOURCE...
     58 */
     59void PrintUsage()
     60{
     61    cout <<
     62        "The console connects to all available Dim Servers and allows to "
     63        "easily access all of their commands.\n"
     64        "\n"
     65        "Usage: test3 [-c type] [OPTIONS]\n"
     66        "  or:  test3 [OPTIONS]\n"
     67        "\n"
     68        "Options:\n"
     69        "The following describes the available commandline options. "
     70        "For further details on how command line option are parsed "
     71        "and in which order which configuration sources are accessed "
     72        "please refer to the class reference of the Configuration class.";
     73    cout << endl;
     74
     75}
     76
     77void PrintHelp()
     78{
     79    /*
     80     cout << "bla bla bla" << endl << endl;
     81     cout << endl;
     82     cout << "Environment:" << endl;
     83     cout << "environment" << endl;
     84     cout << endl;
     85     cout << "Examples:" << endl;
     86     cout << "test exam" << endl;
     87     cout << endl;
     88     cout << "Files:" << endl;
     89     cout << "files" << endl;
     90     cout << endl;
     91     */
     92}
     93
     94/*
     95 The first line of the --version information is assumed to be in one
     96 of the following formats:
     97
     98   <version>
     99   <program> <version>
     100   {GNU,Free} <program> <version>
     101   <program> ({GNU,Free} <package>) <version>
     102   <program> - {GNU,Free} <package> <version>
     103
     104 and separated from any copyright/author details by a blank line.
     105
     106 Handle multi-line bug reporting sections of the form:
     107
     108   Report <program> bugs to <addr>
     109   GNU <package> home page: <url>
     110   ...
     111*/
     112void PrintVersion(const char *name)
     113{
     114    cout <<
     115        name << " - FACT++ 1.0\n"
     116        "\n"
     117        "Written by Thomas Bretz <thomas.bretz@epfl.ch> et al.\n"
     118        "\n"
     119        "Report bugs to Thomas Bretz <thomas.bretz@epfl.ch>\n"
     120        "FACT++ home page: http://www.xxx.com\n"
     121        "\n"
     122        "Copyright (C) 2011 by the FACT Collaboration.\n"
     123        "This is free software; see the source for copying conditions.\n"
     124        << endl;
     125}
     126
    50127int main(int argc, char *argv[])
    51128{
    52     cout << "Starting " << argv[0] << "..." << endl;
    53 
    54129    Configuration conf(argv[0]);
     130    conf.SetPrintUsage(PrintUsage);
    55131    SetupConfiguration(conf);
    56132
     
    74150    }
    75151
    76     if (conf.HasHelp() || conf.HasPrint())
     152    if (conf.HasPrint())
    77153        return -1;
     154
     155    if (conf.HasVersion())
     156    {
     157        PrintVersion(argv[0]);
     158        return -1;
     159    }
     160
     161    if (conf.HasHelp())
     162    {
     163        PrintHelp();
     164        return -1;
     165    }
    78166
    79167    // To allow overwriting of DIM_DNS_NODE set 0 to 1
Note: See TracChangeset for help on using the changeset viewer.