1 // Copyright 2014 The Bazel Authors. All rights reserved.
2 //
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 
15 package com.google.devtools.common.options;
16 
17 import com.google.devtools.common.options.OptionsParser.OptionValueDescription;
18 import com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription;
19 
20 import 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  */
26 public 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    */
getResidue()32   List<String> getResidue();
33 
34   /**
35    * Returns if the named option was specified explicitly in a call to parse.
36    */
containsExplicitOption(String string)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    */
asListOfUnparsedOptions()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    */
asListOfExplicitOptions()60   List<UnparsedOptionValueDescription> asListOfExplicitOptions();
61 
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    */
asListOfEffectiveOptions()66   List<OptionValueDescription> asListOfEffectiveOptions();
67 
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    */
canonicalize()75   List<String> canonicalize();
76 }
77