ores.cpp.shell-command.command_header

Table of Contents

The class declaration for one entity's shell command unit. The unit owns one submenu of the component's root menu and one process_* handler for each of the four CRUD verbs.

Two substitutions place the output, and both come from {component}, the short component name without the product prefix. The part directory is ores.shell.<component>, so a trading entity writes into projects/ores.shell/trading/. The include path keeps the shared ores.shell/ prefix the other parts use, so a unit moves between the adapter parts without an edit to any #include.

See the Template variable reference for the complete list of available variables and their semantics.

1. Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/cpp_shell_command_header.hpp.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/ores.cpp.shell-command.command_header.org. Edit the org source. }}
{{{cpp_license}}}
{{#domain_entity}}
#ifndef ORES_SHELL_APP_COMMANDS_{{entity_singular_upper}}_COMMANDS_HPP
#define ORES_SHELL_APP_COMMANDS_{{entity_singular_upper}}_COMMANDS_HPP

#include "ores.logging/make_logger.hpp"
#include "ores.nats/service/nats_client.hpp"
#include <ostream>
#include <string>
#include <vector>

namespace cli {

class Menu;

}

namespace ores::shell::app::commands {

/**
 * @brief Every verb {{entity_plural_words}} answer, as one command each.
 *
 * The unit is the entity's own derivation addressed from the REPL, so a verb
 * the model gains appears as a command without an edit here and a verb it
 * loses takes its command with it. What each command asks for follows from its
 * shape: a paged read is addressed by nothing, a write by its write record,
 * and everything else by the key.
 */
class {{entity_singular}}_commands {
private:
    inline static std::string_view logger_name =
        "ores.shell.app.commands.{{component}}.{{entity_singular}}_commands";

    static auto& lg() {
        using namespace ores::logging;
        static auto instance = make_logger(logger_name);
        return instance;
    }

public:
    /**
     * @brief Register the {{entity_plural_words}} submenu.
     */
    static void register_commands(cli::Menu& root_menu,
                                  ores::nats::service::nats_client& session);
{{#shell.commands}}

    /**
     * @brief {{usage}}
     */
    static void process_{{identifier}}(std::ostream& out,
                                      ores::nats::service::nats_client& session,
                                      const std::vector<std::string>& args);
{{/shell.commands}}
};

}

#endif
{{/domain_entity}}

2. See also

Emacs 29.3 (Org mode 9.6.15)