aboutsummaryrefslogtreecommitdiff
path: root/src/command.cpp
blob: 092d69d0a7004476256d77fa50e0f5d0163023ae (plain)
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
32
33
#include "command.hpp"

namespace wanda
{

std::optional<message> command::message() const
{
    using namespace std::string_literals;
    auto const command = [this] {
        switch (id)
        {
        case command_id::change:
            return "CHANGE"s;
        default:
            return ""s;
        }
    }();

    auto argument_string = std::string{};
    for (int index = 0ul; index < arguments.size(); ++index)
    {
        argument_string += (index) ? "," + arguments[index] : arguments[index];
    }

    if (command.empty())
    {
        return std::nullopt;
    }

    return wanda::message{"C", command, argument_string};
}

} // namespace wanda