1//
2// Copyright 2019 The Abseil Authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      https://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// -----------------------------------------------------------------------------
17// File: parse.h
18// -----------------------------------------------------------------------------
19//
20// This file defines the main parsing function for Abseil flags:
21// `absl::ParseCommandLine()`.
22
23#ifndef ABSL_FLAGS_PARSE_H_
24#define ABSL_FLAGS_PARSE_H_
25
26#include <vector>
27
28#include "absl/base/config.h"
29#include "absl/flags/internal/parse.h"
30
31namespace absl {
32ABSL_NAMESPACE_BEGIN
33
34// ParseCommandLine()
35//
36// Parses the set of command-line arguments passed in the `argc` (argument
37// count) and `argv[]` (argument vector) parameters from `main()`, assigning
38// values to any defined Abseil flags. (Any arguments passed after the
39// flag-terminating delimiter (`--`) are treated as positional arguments and
40// ignored.)
41//
42// Any command-line flags (and arguments to those flags) are parsed into Abseil
43// Flag values, if those flags are defined. Any undefined flags will either
44// return an error, or be ignored if that flag is designated using `undefok` to
45// indicate "undefined is OK."
46//
47// Any command-line positional arguments not part of any command-line flag (or
48// arguments to a flag) are returned in a vector, with the program invocation
49// name at position 0 of that vector. (Note that this includes positional
50// arguments after the flag-terminating delimiter `--`.)
51//
52// After all flags and flag arguments are parsed, this function looks for any
53// built-in usage flags (e.g. `--help`), and if any were specified, it reports
54// help messages and then exits the program.
55std::vector<char*> ParseCommandLine(int argc, char* argv[]);
56
57ABSL_NAMESPACE_END
58}  // namespace absl
59
60#endif  // ABSL_FLAGS_PARSE_H_
61