Sygaldry
Loading...
Searching...
No Matches
help.hpp
1#pragma once
2/*
3Copyright 2023 Travis J. West, https://traviswest.ca, Input Devices and Music Interaction Laboratory
4(IDMIL), Centre for Interdisciplinary Research in Music Media and Technology
5(CIRMMT), McGill University, Montréal, Canada, and Univ. Lille, Inria, CNRS,
6Centrale Lille, UMR 9189 CRIStAL, F-59000 Lille, France
7
8SPDX-License-Identifier: MIT
9*/
10
11#include <boost/pfr.hpp>
12#include "sygah-consteval.hpp"
13
14namespace sygaldry { namespace sygbp {
17struct Help
18{
19 static _consteval auto name() { return "/help"; }
20 static _consteval auto usage() { return ""; }
21 static _consteval auto description() { return "Describe the available commands and their usage"; }
22
23 void _print(auto& log, auto&& command)
24 {
25 if constexpr (requires {command.usage();})
26 log.println(command.name(), " ", command.usage());
27 else
28 log.println(command.name());
29 log.println(" ", command.description());
30 }
31
32 int main(auto& log, auto& commands)
33 {
34 boost::pfr::for_each_field(commands, [&](auto&& command)
35 {
36 _print(log, command);
37 });
38 log.println(name());
39 log.println(" ", description());
40 return 0;
41 }
42};
44
45} }
Definition help.hpp:18