blob: 929de2cb40de8b6706e088bbd077f69efbae8249 [file] [log] [blame]
Austin Schuh36244a12019-09-21 17:52:38 -07001//
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
Austin Schuh36244a12019-09-21 17:52:38 -070026#include <vector>
27
Austin Schuhb4691e92020-12-31 12:37:18 -080028#include "absl/base/config.h"
Austin Schuh36244a12019-09-21 17:52:38 -070029#include "absl/flags/internal/parse.h"
30
31namespace absl {
Austin Schuhb4691e92020-12-31 12:37:18 -080032ABSL_NAMESPACE_BEGIN
Austin Schuh36244a12019-09-21 17:52:38 -070033
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
Austin Schuhb4691e92020-12-31 12:37:18 -080057ABSL_NAMESPACE_END
Austin Schuh36244a12019-09-21 17:52:38 -070058} // namespace absl
59
60#endif // ABSL_FLAGS_PARSE_H_