Skip to content

Commit 120f88a

Browse files
Update readme (#245)
1 parent 53def03 commit 120f88a

File tree

1 file changed

+1
-204
lines changed

1 file changed

+1
-204
lines changed

README.md

Lines changed: 1 addition & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -6,213 +6,10 @@
66
`argparse` is a flexible utility for [D programming language](https://dlang.org/) to parse command line arguments.
77

88
> [!WARNING]
9-
> :warning: Please be aware that current HEAD contains breaking changes comparing to 1.*
9+
> :warning: Version 2.* contains breaking changes comparing to 1.* - see [change log](https://github.com/andrey-zherikov/argparse/releases) for details
1010
>
1111
> :warning: This includes changes in documentation - documentation for 1.* version is [here](https://github.com/andrey-zherikov/argparse/blob/release/1.x/README.md)
1212
13-
## Changes since 1.* version
14-
15-
<details>
16-
<summary>Changelog</summary>
17-
18-
### Breaking changes
19-
20-
* Changes in `Config`:
21-
22-
* Custom error handler function (`Config.errorHandler`) now receives message text with ANSI styling if styling is enabled. One can use `argparse.ansi.getUnstyledText` function to remove any styling - this function returns a range of unstyled `string` objects which can be used as is or `join`'ed into a string if needed: `message.getUnstyledText.join`.
23-
24-
* `Config.addHelp` is renamed to `Config.addHelpArgument`.
25-
26-
* `Config.arraySep` is renamed to `Config.valueSep`.
27-
28-
* `Config.caseSensitive` is replaced with `Config.caseSensitiveShortName`, `Config.caseSensitiveLongName` and `Config.caseSensitiveSubCommand`.
29-
There is also a "new" `Config.caseSensitive` function/property helper that sets all above settings to a specific value.
30-
31-
* `Config.endOfArgs` is renamed to `Config.endOfNamedArgs`.
32-
33-
* `Config.helpStyle` is renamed to `Config.styling`.
34-
35-
* `Config.namedArgChar` is replaced with `Config.shortNamePrefix` and `Config.longNamePrefix`.
36-
37-
* `Config.stylingMode` remains unchanged even if it was set to `autodetect`. One should check `ansiStylingArgument.stdoutStyling`
38-
or `ansiStylingArgument.stderrStyling` to determine whether styling should be enabled.
39-
40-
* `Style.namedArgumentName` is renamed to `Style.argumentName`.
41-
42-
* Underlying type of `ansiStylingArgument` argument is changed. It supports detection and tracking of styling for stdout and stderr
43-
separately: use `ansiStylingArgument.stdoutStyling` and `ansiStylingArgument.stderrStyling` for this.
44-
Also it can be cast to boolean which is an equivalent to `ansiStylingArgument.stdoutStyling`.
45-
46-
So if you use it:
47-
```d
48-
static auto color = ansiStylingArgument;
49-
```
50-
then you should replace
51-
```d
52-
if(args.color == Config.StylingMode.on)
53-
```
54-
with
55-
```d
56-
if(args.color)
57-
// or
58-
if(args.color.stdoutStyling)
59-
// or
60-
if(ansiStylingArgument.stdoutStyling)
61-
```
62-
63-
* `@SubCommands` UDA is removed. One should use `SubCommand` template instead of `SumType`.
64-
All calls to `std.sumtype.match` should be replaced with `matchCmd`.
65-
66-
Simply replace
67-
```d
68-
@SubCommands SumType!(CMD1, CMD2, Default!CMD3) cmd;
69-
...
70-
cmd.match!...;
71-
```
72-
with
73-
```d
74-
SubCommand!(CMD1, CMD2, Default!CMD3) cmd;
75-
...
76-
cmd.matchCmd!...;
77-
```
78-
79-
* `@TrailingArguments` UDA is removed: all command line parameters that appear after double-dash `--` are considered as positional arguments.
80-
So if those parameters are to be parsed, use `@PositionalArgument` instead of `@TrailingArguments`.
81-
82-
* Functions for parsing customization (`PreValidation`, `Parse`, `Validation` and `Action`) now accept functions as runtime parameters instead of template arguments
83-
84-
For example, replace this
85-
```d
86-
.Parse !((string s) { return cast(char) s[1]; })
87-
.Validation!((char v) { return v >= '0' && v <= '9'; })
88-
```
89-
with
90-
```d
91-
.Parse ((string s) { return cast(char) s[1]; })
92-
.Validation((char v) { return v >= '0' && v <= '9'; })
93-
```
94-
95-
* `HideFromHelp` is renamed to `Hidden` and now also hides an argument from shell completion.
96-
97-
* `AllowedValues` now accepts values as run-time parameters, not as template parameters.
98-
99-
For example, replace this
100-
```d
101-
.AllowedValues!(["value1", "value2", value3"])
102-
```
103-
with
104-
```d
105-
.AllowedValues("value1", "value2", value3")
106-
```
107-
108-
* `AllowNoValue` now accepts a value as run-time parameter, not as template parameter.
109-
110-
For example, replace this
111-
```d
112-
.AllowNoValue!"myvalue"
113-
```
114-
with
115-
```d
116-
.AllowNoValue("myvalue")
117-
```
118-
119-
* `RequireNoValue` is renamed to `ForceNoValue` and now accepts a value as run-time parameter, not as template parameter.
120-
121-
For example, replace this
122-
```d
123-
.RequireNoValue!"myvalue"
124-
```
125-
with
126-
```d
127-
.ForceNoValue("myvalue")
128-
```
129-
130-
* `ArgumentValue` is renamed to `AllowedValues`.
131-
132-
For example, replace this
133-
```d
134-
.ArgumentValue("value1", "value2")
135-
```
136-
with
137-
```d
138-
.AllowedValues("value1", "value2")
139-
```
140-
141-
* `parseArgs` template functions that received `newMain` template argument was removed. One should use either `main` template mixin
142-
or non-templated `Result parseArgs(ref COMMAND receiver, string[] args)` function.
143-
144-
* Removed `Result.Error(T...)(string msg, T extraArgs)` function. Users should explicitly specify result code using
145-
`Result.Error(T...)(int resultCode, string msg, T extraArgs)`.
146-
147-
* Dropped support for DMD-2.099.
148-
149-
### Enhancements and bug fixes
150-
151-
* Parsing procedure follows [POSIX.1-2024](https://pubs.opengroup.org/onlinepubs/9799919799/) meaning that `argparse` now
152-
allows at most one value per appearance of named argument in command line. This means that `prog --param value1 value2`
153-
is not working anymore by default - `--param` must be repeated: `prog --param value1 --param value2`.
154-
However, `prog --param value1,value2` still works.
155-
156-
To make `argparse` 2.* behave like 1.*, one should set `Config.variadicNamedArgument` to true.
157-
See [documentation](https://andrey-zherikov.github.io/argparse/config.html#variadicNamedArgument) for details.
158-
159-
* Fix for `Command()` UDA: `ArrayIndexError` is not thrown anymore.
160-
161-
* Error messages are printed with `Config.styling` and now have the same styling as help text.
162-
163-
* New `errorMessagePrefix` member in `Config.styling` that determines the style of "Error:" prefix in error messages. This prefix is printed in red by default.
164-
165-
* New checks:
166-
* Argument is not allowed to be in multiple argument groups.
167-
* Subcommand name can't start with `Config.shortNamePrefix` (dash `-` by default) or `Config.longNamePrefix` (double-dash `--` by default).
168-
169-
* Functions for parsing customization (`PreValidation`, `Parse`, `Validation` and `Action`) can now return `Result` through `Result.Success` or `Result.Error` and provide error message if needed.
170-
171-
* Fixes for bundling of single-letter arguments.
172-
For example, the following cases are supported for `bool b; string s;` arguments:
173-
* `./prog -b -s=abc`
174-
* `./prog -b -s abc`
175-
* `./prog -b -sabc`
176-
* `./prog -bsabc`
177-
* `./prog -bs=abc`
178-
179-
* Fixes for parsing of multiple values. Only these formats are supported:
180-
* `./prog --arg value1 value2 value3`
181-
* `./prog --arg=value1,value2,value3`
182-
183-
* Values of multi-value positional argument can now be interleaved with named arguments.
184-
For example, the following is the same when `arg1` and `arg2` are values for single `string[] args` positional argument:
185-
* `--flag arg1 arg2`
186-
* `arg1 --flag arg2`
187-
* `arg1 arg2 --flag`
188-
189-
* Long and short names of arguments are now separated:
190-
* Short names are single-character names by default. This can be overridden by explicitly specifying short and long names in `NamedArgument` UDA.
191-
* Short names can be specified with short prefix only (e.g. `-`).
192-
* Long names can be specified with long prefix only (e.g. `--`).
193-
194-
* Removed support for delegate in `Config.errorHandler`, `Description`, `ShortDescription`, `Usage` and `Epilog` because of compiler's `closures are not yet supported in CTFE`.
195-
196-
* Added new `Config.assignKeyValueChar` parameter to customize assign character in `key=value` syntax for arguments with associative array type.
197-
198-
* Added new `Config.errorExitCode` parameter to customize exit code in case of parsing error.
199-
200-
* Added support of `@PositionalArgument` without explicit position. In this case positions are determined in the order of declarations of members.
201-
202-
* Added support for environment fallback, so adding `EnvFallback("VAR")` to an argument would automatically populate the argument with the content
203-
of the `VAR` environment variable if nothing is provided on the command line.
204-
205-
* Fix for empty argument values: they are now non-null empty strings (`""` instead of `string.init` before).
206-
207-
* Added support for classes.
208-
209-
### Other changes
210-
211-
* Removed dependency on `std.regex`.
212-
* New code base: library implementation is almost fully rewritten (public API was not changed in this effort). Unnecessary templates were replaced with regular functions. As a result, compilation time and memory usage were improved: 2x better for `dub build` and 4x better for `dub test`.
213-
* [New documentation](https://andrey-zherikov.github.io/argparse/)
214-
</details>
215-
21613

21714
## Features
21815

0 commit comments

Comments
 (0)