feat: Enhance chat command with multiple output formats and improve help documentation

- Updated the chat command to support new output formats: text, markdown, json, and compact.
- Modified the agent configuration to include output format settings.
- Enhanced the command line interface to handle new format options and provide detailed usage instructions.
- Improved the message printing logic in SimpleChatSession to format output based on the selected format.
- Added JSON and Markdown formatting for session metrics and messages.
- Updated help documentation to reflect changes in command usage and available options.
This commit is contained in:
scawful
2025-10-04 13:33:19 -04:00
parent 0db71a71fe
commit 6990e565b8
8 changed files with 736 additions and 75 deletions

View File

@@ -30,6 +30,8 @@ struct ParsedGlobals {
std::vector<char*> positional;
bool show_help = false;
bool show_version = false;
bool list_commands = false;
std::optional<std::string> help_category;
std::optional<std::string> error;
};
@@ -54,8 +56,22 @@ ParsedGlobals ParseGlobalFlags(int argc, char* argv[]) {
continue;
}
if (absl::StartsWith(token, "--help=")) {
std::string category(token.substr(7));
if (!category.empty()) {
result.help_category = category;
} else {
result.show_help = true;
}
continue;
}
if (token == "--help" || token == "-h") {
result.show_help = true;
if (i + 1 < argc && argv[i + 1][0] != '-') {
result.help_category = std::string(argv[++i]);
} else {
result.show_help = true;
}
continue;
}
@@ -69,6 +85,23 @@ ParsedGlobals ParseGlobalFlags(int argc, char* argv[]) {
continue;
}
if (token == "--list-commands" || token == "--list") {
result.list_commands = true;
continue;
}
if (absl::StartsWith(token, "--quiet=")) {
std::string value(token.substr(8));
bool enable = value.empty() || value == "1" || value == "true";
absl::SetFlag(&FLAGS_quiet, enable);
continue;
}
if (token == "--quiet" || token == "-q") {
absl::SetFlag(&FLAGS_quiet, true);
continue;
}
if (absl::StartsWith(token, "--rom=")) {
absl::SetFlag(&FLAGS_rom, std::string(token.substr(6)));
continue;
@@ -200,6 +233,16 @@ int main(int argc, char* argv[]) {
yaze::cli::ModernCLI cli;
if (globals.help_category.has_value()) {
cli.PrintCategoryHelp(*globals.help_category);
return EXIT_SUCCESS;
}
if (globals.list_commands) {
cli.PrintCommandSummary();
return EXIT_SUCCESS;
}
if (globals.show_help) {
cli.PrintTopLevelHelp();
return EXIT_SUCCESS;