morph
0.1.0
Asynchronous bridge between GUI thread and business models
Toggle main menu visibility
Loading...
Searching...
No Matches
args.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
#pragma once
3
4
#include <expected>
5
#include <optional>
6
#include <string>
7
#include <vector>
8
9
/// @file
10
/// @brief The generic client's command line: which source it opens and how it starts. Spec 4 §3.
11
///
12
/// Specified in `docs/spec/client/client.md`.
13
14
namespace
morph::client {
15
16
/// @brief What the generic client reads from its command line.
17
struct
Args
{
18
/// @brief `--server URL`: the server to fetch the screens from.
19
std::optional<std::string>
server
;
20
/// @brief `--app NAME`: the linked application to run in-process.
21
std::optional<std::string>
app
;
22
/// @brief `--db PATH`: the database a local application opens.
23
std::string
db
;
24
/// @brief `--user NAME`: the development principal a local application signs in.
25
std::string
user
;
26
/// @brief `--screen ID`: the screen mounted first; empty for the catalog's first.
27
std::string
screen
;
28
/// @brief `--exit-after-mount`: quit once the first screen mounted, with 0 when it mounted cleanly.
29
bool
exitAfterMount
=
false
;
30
/// @brief `--dev`, or `MORPH_UI_DEV=1`: development mode, which reloads the screens when the server's documents
31
/// change (spec 5 §12). A client built without the development tools ignores it.
32
bool
dev
=
false
;
33
};
34
35
/// @brief Reads the client's options from @p args and removes them, leaving the rest for the frontend.
36
///
37
/// Each value option is `--name value` or `--name=value`, and the last one given wins. `args[0]` is the program
38
/// name, and nothing after a `--` is read.
39
/// @param args The command line; what was read is removed.
40
/// @return The options, or why they are refused: a value option without its value, or not exactly one of
41
/// `--server` and `--app`. @p args is unchanged on a refusal.
42
[[nodiscard]] std::expected<Args, std::string>
readArgs
(std::vector<std::string>& args);
43
44
}
// namespace morph::client
morph::client::readArgs
std::expected< Args, std::string > readArgs(std::vector< std::string > &args)
Reads the client's options from args and removes them, leaving the rest for the frontend.
morph::client::Args
What the generic client reads from its command line.
Definition
args.hpp:17
morph::client::Args::screen
std::string screen
--screen ID: the screen mounted first; empty for the catalog's first.
Definition
args.hpp:27
morph::client::Args::exitAfterMount
bool exitAfterMount
--exit-after-mount: quit once the first screen mounted, with 0 when it mounted cleanly.
Definition
args.hpp:29
morph::client::Args::app
std::optional< std::string > app
--app NAME: the linked application to run in-process.
Definition
args.hpp:21
morph::client::Args::user
std::string user
--user NAME: the development principal a local application signs in.
Definition
args.hpp:25
morph::client::Args::db
std::string db
--db PATH: the database a local application opens.
Definition
args.hpp:23
morph::client::Args::server
std::optional< std::string > server
--server URL: the server to fetch the screens from.
Definition
args.hpp:19
morph::client::Args::dev
bool dev
--dev, or MORPH_UI_DEV=1: development mode, which reloads the screens when the server's documents cha...
Definition
args.hpp:32
morph
client
args.hpp
Generated by
1.17.0