Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcy committed Jul 11, 2024
1 parent da19e02 commit eb77336
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 7 additions & 2 deletions best/cli/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ namespace best {
/// namespace scope in your main file.
///
/// ```
/// best::app MyApp = +[](best::vec<best::strbuf> args) {
/// best::app MyApp = [](MyFlags& args) {
/// // Your code here!
/// };
/// ```
///
/// So, what can go in `args`?
/// So, what can go in `args`? It's a flags struct! See `cli.h` for more
/// information on how to define one. Alternatively, you can simply take zero
/// arguments, and interpret `best::app::argv()` yourself.
///
/// The function must return either `void`, `int`, or a result whose error type
/// is printable.
class app final {
public:
/// # `app::app()`
Expand Down
17 changes: 13 additions & 4 deletions best/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
//!
//! This header provides functionality for parsing CLI flags from program
//! inputs. In `best`, CLI flags are defined as a reflectable struct with
//! usage, flag, parse, and validation information attached to them. This means
//! that it's easy to construct flag structs independently of the actual argv
//! of the program, promoting decoupling.
//! usage, flag, parse, and validation information attached to its fields as
//! tags.
//!
//! This means that it's easy to construct flag structs independently of
//! actual flag parsing: they're "just" structs! This design pattern is heavily
//! inspired by some Rust CLI crates, such as clap, structopt, and argh.
//!
//! For an example flags struct, see `toy_flags.h` and `toy.cc`. Note that
//! the actual parsing functions live in `cli/parser.h`. This is so that this
//! header is comparatively light-weight to the parser header; this header
//! does not pull in reflection.

namespace best {
/// # `best::cli`
///
/// A flags struct parser.
/// A flags struct parser. Currently this has no user-accessible functions, but
/// it does contain all of the types necessary for defining a flags struct.
class cli final {
public:
/// # `cli::visibility`
Expand Down
3 changes: 1 addition & 2 deletions best/cli/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "best/text/strbuf.h"
#include "best/text/utf8.h"

//! Command-line flags.
//!
//! Command-line flag parsing. See `cli.h` for more information.

namespace best {
/// # `best::cli_flags()`
Expand Down

0 comments on commit eb77336

Please sign in to comment.