aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.cli/dispatch_command.ccm
blob: 1ba55bb2c9070617e89046f8634731cc6202861d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * This source code is released into the public domain.
 */

module;

#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>

export module nihil.cli:dispatch_command;

import nihil.util;
import :command;
import :usage_error;

namespace nihil {

/*
 * Invoke a command (which must have been previously registered) using
 * the provided argument vector.
 *
 * The caller should have already stripped the executable name from argv[0]
 * so that the vector starts with the command name.  This is implicitly
 * done if main() uses getopt().
 */
export [[nodiscard]] auto dispatch_command(int argc, char **argv) -> int;

} // namespace nihil