blob: 040aa055a393c66d54ce5b2034b2401c45aab96c [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.common.options;
16
17import com.google.devtools.common.options.OptionsParser.OptionValueDescription;
18import com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription;
19
20import java.util.List;
21
22/**
23 * A read-only interface for options parser results, which does not allow any
24 * further parsing of options.
25 */
26public interface OptionsProvider extends OptionsClassProvider {
27
28 /**
29 * Returns an immutable copy of the residue, that is, the arguments that
30 * have not been parsed.
31 */
32 List<String> getResidue();
33
34 /**
35 * Returns if the named option was specified explicitly in a call to parse.
36 */
37 boolean containsExplicitOption(String string);
38
39 /**
40 * Returns a mutable copy of the list of all options that were specified
41 * either explicitly or implicitly. These options are sorted by priority, and
42 * by the order in which they were specified. If an option was specified
43 * multiple times, it is included in the result multiple times. Does not
44 * include the residue.
45 *
46 * <p>The returned list can be filtered if undocumented, hidden or implicit
47 * options should not be displayed.
48 */
49 List<UnparsedOptionValueDescription> asListOfUnparsedOptions();
50
51 /**
52 * Returns a list of all explicitly specified options, suitable for logging
53 * or for displaying back to the user. These options are sorted by priority,
54 * and by the order in which they were specified. If an option was
55 * explicitly specified multiple times, it is included in the result
56 * multiple times. Does not include the residue.
57 *
58 * <p>The list includes undocumented options.
59 */
Ulf Adamsc725a522015-12-01 11:43:11 +000060 List<UnparsedOptionValueDescription> asListOfExplicitOptions();
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010061
62 /**
63 * Returns a list of all options, including undocumented ones, and their
64 * effective values. There is no guaranteed ordering for the result.
65 */
Ulf Adamsc725a522015-12-01 11:43:11 +000066 List<OptionValueDescription> asListOfEffectiveOptions();
Alex Humeskyc5ac4302016-01-15 19:21:03 +000067
68 /**
69 * Canonicalizes the list of options that this OptionsParser has parsed. The
70 * contract is that if the returned set of options is passed to an options
71 * parser with the same options classes, then that will have the same effect
72 * as using the original args (which are passed in here), except for cosmetic
73 * differences.
74 */
75 List<String> canonicalize();
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010076}