dsw7 / GPTifier

A beautiful C++ libcurl / ChatGPT interface. I more or less work on this project for fun :)
MIT License
0 stars 1 forks source link

Break up help message construction using utility functions #66

Closed dsw7 closed 3 months ago

dsw7 commented 3 months ago

Impetus

Help messages are currently defined as very big string literals. For example, see: https://github.com/dsw7/GPTifier/blob/95d4a81da5a4bf67bec425bfe0d37673e806d57e/GPTifier/src/help_messages.cpp#L13-L31

This is okay... but not great. We can do better. React advertises the concept of components and I think we can use a similar approach here, for example, given: https://github.com/dsw7/GPTifier/blob/95d4a81da5a4bf67bec425bfe0d37673e806d57e/GPTifier/src/help_messages.cpp#L17-L19

We can turn this into a description "component" - something like:


std::string get_description(const std::string &description)
{
    std::string block = "\033[1mDESCRIPTION:\033[0m\n";
    block += description;
    ...
    return block;
}

And this is still perfectly efficient because the compiler will (probably) do some sort of RVO (see this very old discussion).