From 4f4be4b994fbd3f56d556a3ab80725da9acb94d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 27 Apr 2023 10:54:06 +0200 Subject: [PATCH] Add --help message --- src/cli/convert_json_toml.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cli/convert_json_toml.cpp b/src/cli/convert_json_toml.cpp index b8e5bb4de6..c5187ebb89 100644 --- a/src/cli/convert_json_toml.cpp +++ b/src/cli/convert_json_toml.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include @@ -39,6 +41,21 @@ int main(int argc, char const **argv) std::cin >> jsonOrToml; break; case 2: + if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) + { + std::cout << "Usage: " << std::string(argv[0]) << R"( [json_or_toml] +'json_or_toml' can be a JSON or TOML dataset specified inline or a reference +to a file prepended by an '@'. +Inline datasets will be interpreted as JSON if they start with an '{', as TOML +otherwise. Datasets from a file will be interpreted as JSON or TOML depending +on the file ending '.json' or '.toml' respectively. +Inline dataset specifications can be replaced by input read from stdin. + +If the input is JSON, then it will be converted to TOML and written to stdout, +equivalently from TOML to JSON. +)"; + exit(0); + } jsonOrToml = argv[1]; break; default: