container: root: rootlogon: update the help process

- Less noisy, less intrusive, more helpful
- Will allow for isolating usage help on a per-namespace level
This commit is contained in:
2025-11-21 13:04:53 -08:00
parent 9fec1b427c
commit 8eb03f6d95

View File

@@ -24,6 +24,7 @@
#define CONTAINER_SRC_ROOT_MACRO_ROOTLOGON_C_
#include <iostream>
#include <string>
//! \namespace dfi
//! \since docker-finance 1.0.0
@@ -34,146 +35,161 @@ namespace dfi
//! \since docker-finance 1.0.0
namespace macro
{
//! \brief Global namespace help wrapper
//! \brief `dfi` macro-specific usage help
//! \ingroup cpp_macro
//! \since docker-finance 1.0.0
void help()
{
std::cout
<< "Description:\n"
<< "\n"
<< " docker-finance C++ interpretations / interactive calculations\n"
<< "\n"
<< " *** TIP: save your fingers! Use tab completion! ***\n"
<< "\n"
<< " 1. Print current directory (all commands/files are relative to\n"
<< " this directory):\n"
<< "\n"
<< " root [0] .!pwd // eg., "
<< "${DOCKER_FINANCE_CONTAINER_REPO}/src/root/macro\n"
<< "\n"
<< "Library:\n"
<< "\n"
<< " 1. Directly access docker-finance crypto abstractions and\n"
<< " print hundreds of SHA2-256 libsodium-generated hashes\n"
<< " of Crypto++-generated cryptographically secure random\n"
<< " numbers:\n"
<< "\n"
<< " root [0] using g_Random = "
"dfi::crypto::cryptopp::Random;\n"
<< " root [1] using g_Hash = "
"dfi::crypto::libsodium::Hash;\n"
<< " root [2] g_Random r; g_Hash h;\n"
<< " root [3] for (size_t i{}; i < "
"std::numeric_limits<uint8_t>::max(); i++) {\n"
<< " root (cont'ed, cancel with .@) [4] uint32_t num = "
"r.generate();\n"
<< " root (cont'ed, cancel with .@) [5] std::cout << "
"h.encode<g_Hash::SHA2_256>(num)\n"
<< " root (cont'ed, cancel with .@) [6] << \" = \" << num << "
"\"\\n\";\n"
<< " root (cont'ed, cancel with .@) [7] }\n"
<< "\n"
<< " Note: generate Doxygen to see all supported cryptographic\n"
<< " libraries and hash types.\n"
<< "\n"
<< " 2. Use Tools utility\n"
<< "\n"
<< " root [0] dfi::utility::Tools tools;\n"
<< "\n"
<< " // Create a variable within interpreter\n"
<< " root [1] btc=0.87654321+0.12345678+0.00000078\n"
<< " (double) 1.0000008\n"
<< "\n"
<< " // Print variable up to N decimal places\n"
<< " root [2] tools.print_value<double>(btc, 8);\n"
<< " 1.00000077\n"
<< "\n"
<< " // Use tab autocomplete for class members to print random\n"
<< " // numbers within given intervals\n"
<< " root [3] "
"tools.print_dist<TRandomGen<ROOT::Math::MixMaxEngine<240, 0> >, "
"double>(0.1, btc);\n"
<< " 0.13787670\n"
<< " 0.36534066\n"
<< " 0.33885582\n"
<< " 0.15792758\n"
<< " Maximum = 1.00000077\n"
<< " Printed = 1.00000077\n"
<< "\n"
<< "Plugins:\n"
<< "\n"
<< " WARNING: unlike macro loader, the prepended 'repo' and 'custom'\n"
<< " are not real directories but rather indications that the file\n"
<< " is either a repository plugin or an non-repo (custom) plugin.\n"
<< "\n"
<< " 1. Connect to docker-finance API via plugins:\n"
<< "\n"
<< " // Load and run an example repository plugin\n"
<< " root [0] dfi::plugin::load(\"repo/example.cc\");\n"
<< " root [1] "
"dfi::plugin::my_plugin_namespace::example1();\n"
<< " root [2] "
"dfi::plugin::my_plugin_namespace::example2();\n"
<< " root [3] "
"dfi::plugin::my_plugin_namespace::example3();\n"
<< "\n"
<< " // Load and run your own custom plugin\n"
<< " root [4] dfi::plugin::load(\"custom/example.cc\");\n"
<< " root [5] "
"dfi::plugin::your_plugin_namespace::example();\n"
<< "\n"
<< "Macros:\n"
<< "\n"
<< " NOTE: the macro loader interprets from base 'macro' path (.!pwd)\n"
<< "\n"
<< " 1. Load and run docker-finance unit tests and benchmarks:\n"
<< "\n"
<< " root [0] dfi::macro::load(\"test/unit.C\")\n"
<< " root [1] dfi::macro::test::Unit::run()\n"
<< " ...\n"
<< " root [2] dfi::macro::load(\"test/benchmark.C\")\n"
<< " root [3] dfi::macro::test::Benchmark::run()\n"
<< " ...\n"
<< "\n"
<< " 2. Load and run docker-finance cryptographic macros:\n"
<< "\n"
<< " root [0] dfi::macro::load(\"crypto/hash.C\")\n"
<< " root [1] "
<< "dfi::macro::crypto::Hash::run(\"better to be raw than "
"digested\")\n"
<< " ...\n"
<< " root [2] dfi::macro::load(\"crypto/random.C\")\n"
<< " root [3] dfi::macro::crypto::Random::run()\n"
<< " ...\n"
<< "\n"
<< " 3. Load ROOT webserver and run commands for metadata analysis:\n"
<< "\n"
<< " root [0] dfi::macro::load(\"web/server.C\")\n"
<< " root [1] dfi::macro::web::Server::run()\n"
<< "\n"
<< " Now, open your web browser to http://127.0.0.1:8080\n"
<< "\n"
<< "Help:\n"
<< "\n"
<< " 1. Print ROOT's help usage\n"
<< " root [0] .help\n"
<< "\n"
<< " 2. Print this help usage\n"
<< " root [0] help()\n"
<< std::endl;
// TODO(unassigned): add multi-threading example of generating numbers and/or hashes
std::cout << "Use `dfi::help()` instead" << std::endl;
}
} // namespace macro
} // namespace dfi
//! \brief `dfi` generic help descriptions
//! \ingroup cpp_macro
//! \todo Factor out for specific help descriptions per-namespace
//! (e.g., dfi::macro::help())
//! \since docker-finance 1.1.0
void help()
{
dfi::macro::help();
const std::string help =
"Description:\n"
"\n"
" docker-finance C++ interpretations / interactive calculations\n"
"\n"
" *** TIP: save your fingers! Use tab completion! ***\n"
"\n"
" 1. Print current directory (all commands/files are relative to\n"
" this directory):\n"
"\n"
" root [0] .!pwd // eg., "
"${DOCKER_FINANCE_CONTAINER_REPO}/src/root\n"
"\n"
"Library:\n"
"\n"
" 1. Directly access docker-finance crypto abstractions and\n"
" print hundreds of SHA2-256 libsodium-generated hashes\n"
" of Crypto++-generated cryptographically secure random\n"
" numbers:\n"
"\n"
" root [0] using g_Random = dfi::crypto::cryptopp::Random;\n"
" root [1] using g_Hash = dfi::crypto::libsodium::Hash;\n"
" root [2] g_Random r; g_Hash h;\n"
" root [3] for (size_t i{}; i < "
"std::numeric_limits<uint8_t>::max(); i++) {\n"
" root (cont'ed, cancel with .@) [4] uint32_t num = r.generate();\n"
" root (cont'ed, cancel with .@) [5] std::cout << "
"h.encode<g_Hash::SHA2_256>(num)\n"
" root (cont'ed, cancel with .@) [6] << \" = \" << num << \"\\n\";\n"
" root (cont'ed, cancel with .@) [7] }\n"
"\n"
" Note: generate Doxygen to see all supported cryptographic\n"
" libraries and hash types.\n"
"\n"
" 2. Use Tools utility\n"
"\n"
" root [0] dfi::utility::Tools tools;\n"
"\n"
" // Create a variable within interpreter\n"
" root [1] btc=0.87654321+0.12345678+0.00000078\n"
" (double) 1.0000008\n"
"\n"
" // Print variable up to N decimal places\n"
" root [2] tools.print_value<double>(btc, 8);\n"
" 1.00000077\n"
"\n"
" // Use tab autocomplete for class members to print random\n"
" // numbers within given intervals\n"
" root [3] "
"tools.print_dist<TRandomGen<ROOT::Math::MixMaxEngine<240, 0> >, "
"double>(0.1, btc);\n"
" 0.13787670\n"
" 0.36534066\n"
" 0.33885582\n"
" 0.15792758\n"
" Maximum = 1.00000077\n"
" Printed = 1.00000077\n"
"\n"
"Plugins:\n"
"\n"
" WARNING: unlike macro loader, the prepended 'repo' and 'custom'\n"
" are not real directories but rather indications that the file\n"
" is either a repository plugin or an non-repo (custom) plugin.\n"
"\n"
" 1. Connect to docker-finance API via plugins:\n"
"\n"
" // Load and run an example repository plugin\n"
" root [0] dfi::plugin::load(\"repo/example.cc\");\n"
" root [1] dfi::plugin::my_plugin_namespace::example1();\n"
" root [2] dfi::plugin::my_plugin_namespace::example2();\n"
" root [3] dfi::plugin::my_plugin_namespace::example3();\n"
"\n"
" // Load and run your own custom plugin\n"
" root [4] dfi::plugin::load(\"custom/example.cc\");\n"
" root [5] dfi::plugin::your_plugin_namespace::example();\n"
"\n"
"Macros:\n"
"\n"
" NOTE: the macro loader interprets from base 'macro' path (.!pwd)\n"
"\n"
" 1. Load and run docker-finance unit tests and benchmarks:\n"
"\n"
" root [0] dfi::macro::load(\"macro/test/unit.C\")\n"
" root [1] dfi::macro::test::Unit::run()\n"
" ...\n"
" root [2] dfi::macro::load(\"macro/test/benchmark.C\")\n"
" root [3] dfi::macro::test::Benchmark::run()\n"
" ...\n"
"\n"
" 2. Load and run docker-finance cryptographic macros:\n"
"\n"
" root [0] dfi::macro::load(\"macro/crypto/hash.C\")\n"
" root [1] dfi::macro::crypto::Hash::run(\"better to be raw than "
"digested\")\n"
" ...\n"
" root [2] dfi::macro::load(\"macro/crypto/random.C\")\n"
" root [3] dfi::macro::crypto::Random::run()\n"
" ...\n"
"\n"
" 3. Load ROOT webserver and run commands for metadata analysis:\n"
"\n"
" root [0] dfi::macro::load(\"macro/web/server.C\")\n"
" root [1] dfi::macro::web::Server::run()\n"
"\n"
" Now, open your web browser to http://127.0.0.1:8080\n"
"\n"
"Help:\n"
"\n"
" 1. Print all help options\n"
"\n"
" root [0] help()\n";
// TODO(unassigned): add multi-threading example of generating numbers and/or hashes
std::cout << help << std::endl;
}
} // namespace dfi
//! \brief Print all help options
//! \ingroup cpp_macro
//! \since docker-finance 1.0.0
void help()
{
const std::string help =
"Help:\n"
"\n"
" 1. Print this help\n"
" root [0] help()\n"
"\n"
" 2. Print `root` help\n"
" root [0] .help\n"
"\n"
" 3. Print `dfi` help\n"
" root [0] dfi::help()\n";
std::cout << help << std::endl;
}
//! \brief ROOT logon macro, runs on `root` startup
//! \since docker-finance 1.0.0
void rootlogon()
{
// Add nested directory headers