1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 23:00:50 +08:00
Commit Graph

26 Commits

Author SHA1 Message Date
Taylor Sasser
aaeffdfe6b cmArgumentParser: Refactor to allow for nested parsers 2025-07-23 09:42:05 -04:00
Vito Gamberini
7238c8c999 ArgumentParser: implement HasKeyword helper 2025-07-08 17:44:07 -04:00
Matthew Woehlke
5eec48ee40 cmArgumentParser: Simplify assignment of marker types
Explicitly allow argument markers to be assigned. Make use of this in
parsing. This simplifies working with these types, by allowing them to
be assigned from the underlying types using simple `a = b` syntax,
rather than requiring gymnastics to access the underlying assignment
operations. It also makes assignment more consistent with
initialization.
2025-05-30 11:10:41 -04:00
Vito Gamberini
df870e17f5 cmArgumentParser: Implement trailing positional args 2025-04-16 14:15:48 -04:00
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Alex Turbov
cc20644c71 testCommon.h: Introduce ASSERT_EQUAL(actual, expected) macro
Performs `==` on given arguments and print an error if they are
not equal also printing their values.

Both arguments must be printable to `std::ostream`!
2024-08-21 02:24:16 +04:00
Alex Turbov
0146fca12d CMakeLibTests: include testCommon.h for ASSERT_TRUE
And remove duplicate definitions.
2024-08-14 01:04:15 +04:00
Vito Gamberini
5fc2bad167 cmArgumentParser: Support binding with derived classes 2024-07-02 09:58:57 -04:00
Kitware Robot
33abef7416 Revise C++ coding style using clang-format-15
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 15.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Fixes: #24315
2023-01-18 16:20:47 -05:00
Matthew Woehlke
f2ef60ca54 cmArgumentParser: Ignore positional after keyword
Tweak cmArgumentParser to ignore positional arguments once a keyword
argument has been seen. This prevents mingling of keyword arguments
being able to effectively skip positional arguments, with later
arguments being picked up again; this seems highly likely to lead to
user confusion. This is also consistent with how other languages (e.g.
Python) handle a mix of "named" and positional arguments.
2022-08-17 11:03:51 -04:00
Brad King
7ca8d9f0f8 cmArgumentParser: Model non-empty strings with wrapper type
Some clients have been explicitly checking whether the string specified
after a keyword is empty.  Offer them a way to specify that the string
must be non-empty as part of the binding type.
2022-07-28 08:24:47 -04:00
Brad King
236bacc244 cmArgumentParser: Offer bindings for positional arguments 2022-07-27 07:03:32 -04:00
Brad King
1f2eb63d1c cmArgumentParser: Add callback bindings 2022-07-27 07:03:32 -04:00
Brad King
77fcb00a2b cmArgumentParser: Propagate constructors through binding wrapper types 2022-07-27 07:03:31 -04:00
Brad King
f7e81802f2 cmArgumentParser: Offer binding for list of parsed keywords
Some clients ask for this list in their `Parse()` call.
Offer them a way to express this request as a binding.
2022-07-25 13:52:01 -04:00
Brad King
f95a5832c7 cmArgumentParser: Drop unused keywordsMissingValue argument to Parse()
All clients have been converted to encoding this requirement in their
bindings.
2022-07-25 13:51:43 -04:00
Brad King
b7c82b26b0 cmArgumentParser: Capture keyword errors in parse results
Since commit f46b2e9142 (cmArgumentParser: Model maybe-missing string
with wrapper type, 2022-07-06) we know during parsing whether or not it
is an error for a keyword to be missing a value.  Record such errors in
the parse results structure.  Offer clients a helper method to report
them.  This provides clients with an alternative to manually checking
`keywordsMissingValue` and generating their own error message.
2022-07-22 10:32:24 -04:00
Brad King
50876f6b9a cmArgumentParser: Add structure to capture operational results
Create a way for the parser to record errors or incidental information
about the argument parsing operation that clients can inspect afterward.
Offer clients a way to hold the structure as part of their arguments
structure.
2022-07-22 10:32:18 -04:00
Brad King
f46b2e9142 cmArgumentParser: Model maybe-missing string with wrapper type
Bindings to `std::string` require one value.  Some clients have been
filtering `keywordsMissingValue` to support keywords that tolerate a
missing value.  Offer them a type-safe way to achieve this instead.
2022-07-07 09:49:04 -04:00
Brad King
e6d1e29ffa cmArgumentParser: Model maybe-empty and non-empty lists with wrapper types
Previously bindings to `std::vector<std::string>` required at least one
value.  Some clients have been filtering `keywordsMissingValue` to
support keywords followed by empty lists.  Instead, require clients to
specify whether a keyword's list can be empty as part of the binding
type.
2022-07-07 09:48:58 -04:00
Brad King
0a4c5164c9 cmArgumentParser: Offer cm::optional bindings to capture keyword presence
Several clients have been using `keywordsMissingValue` or
`parsedKeywords` to check for the presence of keywords.  Offer them a
type-encoded way to explicitly check whether a keyword is present.
2022-07-05 16:35:01 -04:00
Brad King
1ee5a4a548 cmArgumentParser: Avoid allocating copies of keyword strings 2022-07-05 16:34:57 -04:00
Marc Chevrier
8d4a9ee398 Refactoring: rename "cm_static_string_view.hxx" as <cmext/string_view> 2020-04-30 09:53:27 +02:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Regina Pfeifer
4359fe133b Introduce cmArgumentParser 2019-04-04 13:24:39 -04:00