Skip to content

Commit 4f103e7

Browse files
committed
docs: update README to reflect library rewrite
1 parent 7911b62 commit 4f103e7

1 file changed

Lines changed: 34 additions & 54 deletions

File tree

README.md

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,62 +20,52 @@ The goals of this library, in order of importance, are:
2020
It's also very closely related to the previous goal.
2121
We should be able to detect most errors at compile-time and provide decent diagnostics.
2222

23-
1. **_Try_ not to repeat yourself.**
23+
1. **Don't repeat yourself.**
2424

25-
When specifying a CLI, if some information was already given to the library, that same information should not be needed again.
26-
For example, if the type of an argument was already specified, the user should not be asked to tell the type again.
27-
Unfortunately that is very hard, so some places still require duplicate information.
25+
When specifying the CLI, if some information was already given to the library, that same information should not be needed again.
26+
For example, the type of an argument is always known during setup, so the user should not be asked to inform the type when querying that argument.
2827

2928
1. **Be bleeding-edge.**
3029

31-
This library requires C++20.
32-
That limits a lot its potential users, but also allows for the use of the new and powerful features of C++.
30+
This isn't really a goal, but a fact: this library requires C++23.
31+
That limits a lot its potential users (so there are plans to at least go back to C++20),
32+
but also allows for the use of the new and powerful features of C++.
3333
It also helps to accomplish the previous goals.
3434

3535
## Disclaimer
3636

3737
- This is a **personal project** with **no promise of maintainability** for the time being.
3838

39-
I started it to learn more about C++ and its new features.
39+
- I have just rewritten the entire library, so **it is neither stable nor production-ready**.
4040

41-
- Although it is *not* in *early* development, since I'm working on it for months and iterated over it many times,
42-
**it is not stable or production-ready**.
43-
44-
- There are **many unit tests missing**.
45-
46-
- I frequently changed the interface of the library and I'm **not afraid of changing it radically again** if I think it would improve the UX.
47-
48-
Another example is the names of the `namespaces` and what is in them.
41+
- There are **no unit tests** (since the rewrite).
4942

5043
- There is *a lot* of polish and optimization work to do.
5144

5245
- There is a whole documentation to write.
5346

5447
## Sneak peek
5548

56-
The code below is a fully working example, taken from [`examples/hello.cpp`][examples/hello], only reformatted and with quotes changed to angle brackets in the `#include`.
49+
The code below is a fully working example, taken from [`examples/hello.cpp`](examples/hello.cpp),
50+
only with quotes changed to angle brackets in the `#include`.
5751
Feel free to take a look at the other, more complex, examples in the same directory.
5852

5953
```cpp
60-
#include <iostream>
61-
#include <string_view>
54+
#include <print>
55+
#include <variant>
6256

63-
#include <opzioni.hpp>
57+
#include <opzioni/all.hpp>
6458

6559
int main(int argc, char const *argv[]) {
66-
using namespace opzioni;
67-
68-
constexpr auto hello =
69-
Program("hello")
70-
.version("0.1")
71-
.intro("Greeting people since the dawn of computing")
72-
.add(Pos("name").help("Your name please, so I can greet you"))
73-
.add(Help())
74-
.add(Version());
75-
76-
auto const args = hello(argc, argv);
77-
std::string_view const name = args["name"];
78-
std::cout << "Hello, " << name << "!\n";
60+
auto hello_cmd = opz::new_cmd("hello", "1.0")
61+
.intro("Greeting people since the dawn of computing")
62+
.pos<"name">({.help = "Your name please, so I can greet you"})
63+
.flg<"help", "h">(opz::default_help)
64+
.flg<"version", "v">(opz::default_version);
65+
66+
auto const map = opz::parse(hello_cmd, argc, argv);
67+
auto const name = map.get<"name">();
68+
std::print("Hello, {}!\n", name);
7969
}
8070
```
8171
@@ -85,36 +75,33 @@ That gives us:
8575
8676
```
8777
$ ./build/examples/hello -h
88-
hello 0.1
78+
hello 1.0
8979
9080
Greeting people since the dawn of computing
9181
9282
Usage:
9383
hello <name> [--help] [--version]
94-
84+
9585
Positionals:
9686
name Your name please, so I can greet you
9787
9888
Options & Flags:
9989
-h, --help Display this information
100-
-V, --version Display the software version
90+
-v, --version Display hello's version
10191
```
10292
103-
1. Automatic version with `--version` or `-V`
93+
1. Automatic version with `--version` or `-v`
10494
10595
```
106-
$ ./build/examples/hello -V
107-
hello 0.1
96+
$ ./build/examples/hello -v
97+
hello 1.0
10898
```
10999
110-
1. Automatic error handling
100+
1. Automatic error handling (_WIP_)
111101
112102
```
113103
$ ./build/examples/hello Gabriel Galli
114-
Unexpected positional argument `Galli`. This program expects 1 positional arguments
115-
116-
Usage:
117-
hello <name> [--help] [--version]
104+
libc++abi: terminating due to uncaught exception of type opz::UnexpectedPositional: Unexpected positional argument for `hello`: `Galli` (1 are expected)
118105
```
119106
120107
1. And finally:
@@ -131,8 +118,9 @@ Meanwhile, it is kinda straightforward to build it locally, since just a simple
131118
The build system is the awesome [Meson](https://mesonbuild.com/).
132119
133120
1. Download and install conda if you haven't already.
134-
Just grab a suitable installer from [here](https://docs.conda.io/en/latest/miniconda.html) and run it.
135-
There's also an install guide [here](https://conda.io/projects/conda/en/latest/user-guide/install/index.html).
121+
122+
You can either use [miniforge](https://conda-forge.org) (recommended, personally),
123+
or [miniconda](https://www.anaconda.com/docs/getting-started/miniconda/main).
136124
137125
1. Clone this repository:
138126
@@ -163,7 +151,7 @@ Feel free to inspect it and not use it.
163151
164152
## License
165153
166-
opzioni's license is the [Boost Software License (BSL) 1.0][license].
154+
opzioni's license is the [Boost Software License (BSL) 1.0](LICENSE).
167155
168156
This means you are **free to use** this library **as you wish** and see fit.
169157
@@ -176,11 +164,3 @@ In other words, **there is no need to bundle opzioni's license with your binary*
176164
[![](docs/src/assets/images/jetbrains-variant-3.svg)](https://www.jetbrains.com/?from=opzioni)
177165
178166
Thank you to [JetBrains](https://www.jetbrains.com/?from=opzioni) for supporting this project by providing free access to its products as part of the Open Source Licenses program.
179-
180-
<!-- links -->
181-
[issues/5]: https://github.com/ggabriel96/opzioni/issues/5
182-
[examples/hello]: https://github.com/ggabriel96/opzioni/blob/main/examples/hello.cpp
183-
[.devcontainer]: https://github.com/ggabriel96/opzioni/blob/main/.devcontainer/
184-
[Makefile]: https://github.com/ggabriel96/opzioni/blob/main/Makefile
185-
[shell.nix]: https://github.com/ggabriel96/opzioni/blob/main/shell.nix
186-
[license]: https://github.com/ggabriel96/opzioni/blob/main/LICENSE

0 commit comments

Comments
 (0)