GRPC Core  5.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cmdline.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_SUPPORT_CMDLINE_H
20 #define GRPC_SUPPORT_CMDLINE_H
21 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
54 typedef struct gpr_cmdline gpr_cmdline;
55 
58 GPRAPI gpr_cmdline* gpr_cmdline_create(const char* description);
61 GPRAPI void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name,
62  const char* help, int* value);
64 GPRAPI void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name,
65  const char* help, int* value);
67 GPRAPI void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name,
68  const char* help, const char** value);
71  gpr_cmdline* cl, const char* name, const char* help,
72  void (*on_extra_arg)(void* user_data, const char* arg), void* user_data);
78 GPRAPI int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv);
82 GPRAPI char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* GRPC_SUPPORT_CMDLINE_H */
struct gpr_cmdline gpr_cmdline
Simple command line parser.
Definition: cmdline.h:54
GPRAPI char * gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0)
Get a string describing usage.
GPRAPI int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv)
Parse the command line; returns 1 on success, on failure either dies (by default) or returns 0 if gpr...
#define GPRAPI
Definition: port_platform.h:440
GPRAPI void gpr_cmdline_destroy(gpr_cmdline *cl)
Destroy the parser.
GPRAPI gpr_cmdline * gpr_cmdline_create(const char *description)
Construct a command line parser: takes a short description of the tool doing the parsing.
GPRAPI void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name, const char *help, const char **value)
And for a string.
GPRAPI void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name, const char *help, int *value)
Add an integer parameter, with a name (used on the command line) and some helpful text (used in the c...
GPRAPI void gpr_cmdline_on_extra_arg(gpr_cmdline *cl, const char *name, const char *help, void(*on_extra_arg)(void *user_data, const char *arg), void *user_data)
Set a callback for non-named arguments.
GPRAPI void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name, const char *help, int *value)
The same, for a boolean flag.
GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline *cl)
Enable surviving failure: default behavior is to exit the process.