Listing 1: Sample program that uses command-line parser

#include <iostream.h>
#include "Application.h"

class CMyTelnet : public CApp {
public:
    CApp::CToggleArg  m_no_read_telrc;
    CApp::CToggleArg  m_rlogin_ui;
    CApp::CCstringArg m_login_name;
    CApp::CCstringArg m_file_name;
    CApp::CCstringArg m_host;
    CApp::CIntArg     m_port;

    CMyTelnet();
};

extern CMyTelnet the_app;

CMyTelnet::CMyTelnet() :
   m_no_read_telrc("c", "Disables read of user's telnetrc  file", 0),
   m_rlogin_ui    ("r", "Use rlogin semantics", 0),
   m_login_name   ("l", "Use this login name instead of curr. user", ""),
   m_file_name    ("n", "Open this trace file", NULL),
   m_host         ("host", "The host to connect", NULL,
CApp::fl_arg|CApp::fl_req), m_port ("port", "The port to use", 23, CApp::fl_arg) {}; CMyTelnet the_app; int main(int argc, char*argv[]) { the_app.parse(argc, argv); cout << "-c is " << the_app.m_no_read_telrc() << endl; cout << "-r is " << the_app.m_rlogin_ui() << endl; cout << "login name" << the_app.m_login_name() << endl; return 0; } //End of File