NCBI C++ ToolKit
clparser.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONNECT_SERVICES__CLI__HPP
2 #define CONNECT_SERVICES__CLI__HPP
3 
4 /* $Id: clparser.hpp 66550 2015-03-11 18:47:49Z kazimird $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Dmitry Kazimirov
30  *
31  */
32 
33 /// @file cli.hpp
34 /// Command line handlers.
35 ///
36 
37 
38 #include "netcomponent.hpp"
39 
40 
42 
44 
46 {
47  NCBI_NET_COMPONENT(CommandLineParser);
48 
50  const string& program_name,
51  const string& version_info,
52  const string& program_summary,
53  const string& program_description = kEmptyStr);
54 
55  void SetHelpTextMargins(
56  int help_text_width,
57  int cmd_descr_indent,
58  int opt_descr_indent);
59 
60  enum EOptionType {
66  eOneOrMorePositional
67  };
68 
69  void AddOption(
70  EOptionType type,
71  int opt_id,
72  const string& name_variants,
73  const string& description);
74 
75  void AddCommandCategory(
76  int cat_id,
77  const string& title);
78 
79  void AddCommand(
80  int cmd_id,
81  const string& name_variants,
82  const string& synopsis,
83  const string& usage,
84  int cat_id = -1);
85 
86  void AddAssociation(int cmd_id, int opt_id);
87 
88  /// Parse the command line. Print program version or the help screen
89  /// if requested by the command line arguments.
90  /// @return One of the command identifiers or -1 if the requested
91  /// command is either help or version command, in which
92  /// case it has been already processed by this method, and
93  /// the caller must immediately exit with return code 0.
94  int Parse(int argc, const char* const *argv);
95 
96  const string& GetProgramName() const;
97 
98  bool NextOption(int* opt_id, const char** opt_value);
99 };
100 
101 /////////////////////////////////////////////////////////////////////////////
102 
104 
105 #endif // CONNECT_SERVICES__CLI__HPP
const char * usage
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_XCONNECT_EXPORT
#define GetProgramName
Avoid name clash with the NCBI C Toolkit.
Definition: ncbienv.hpp:49
#define NCBI_NET_COMPONENT(component)
Definition: type.c:6
Modified on Wed Apr 17 13:10:37 2024 by modify_doxy.py rev. 669887