container: plugins: root: example: rename Example class
For clarity that this class is separate from plugin's entrypoint.
This commit is contained in:
@@ -57,7 +57,7 @@ class example_cc final
|
|||||||
example_cc& operator=(example_cc&&) = default;
|
example_cc& operator=(example_cc&&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Example auto-loader
|
//! \brief Example plugin's auto-loader
|
||||||
//! \param arg String to pass to auto-loader (use-case is plugin-implementation defined)
|
//! \param arg String to pass to auto-loader (use-case is plugin-implementation defined)
|
||||||
static void load(const std::string& arg = {})
|
static void load(const std::string& arg = {})
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ class example_cc final
|
|||||||
common::line(arg);
|
common::line(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Example auto-unloader
|
//! \brief Example plugin's auto-unloader
|
||||||
//! \param arg String to pass to auto-unloader (use-case is plugin-implementation defined)
|
//! \param arg String to pass to auto-unloader (use-case is plugin-implementation defined)
|
||||||
static void unload(const std::string& arg = {})
|
static void unload(const std::string& arg = {})
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// docker-finance | modern accounting for the power-user
|
// docker-finance | modern accounting for the power-user
|
||||||
//
|
//
|
||||||
// Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
// Copyright (C) 2024-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,12 +26,14 @@
|
|||||||
|
|
||||||
namespace dfi::plugin::example
|
namespace dfi::plugin::example
|
||||||
{
|
{
|
||||||
std::string Example::make_cmd(const std::string& base, const std::string& arg)
|
std::string MyExamples::make_cmd(
|
||||||
|
const std::string& base,
|
||||||
|
const std::string& arg)
|
||||||
{
|
{
|
||||||
return std::string{base + arg};
|
return std::string{base + arg};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Example::exec_cmd(const std::string& cmd)
|
void MyExamples::exec_cmd(const std::string& cmd)
|
||||||
{
|
{
|
||||||
namespace common = ::dfi::common;
|
namespace common = ::dfi::common;
|
||||||
|
|
||||||
@@ -42,16 +44,16 @@ void Example::exec_cmd(const std::string& cmd)
|
|||||||
+ common::get_env("global_child_profile") + " "};
|
+ common::get_env("global_child_profile") + " "};
|
||||||
|
|
||||||
common::throw_ex_if<common::type::RuntimeError>(
|
common::throw_ex_if<common::type::RuntimeError>(
|
||||||
common::exec("bash -i -c '" + Example::make_cmd(base, cmd) + "'"),
|
common::exec("bash -i -c '" + MyExamples::make_cmd(base, cmd) + "'"),
|
||||||
"command failed");
|
"command failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Example::print_env(const std::string& env)
|
void MyExamples::print_env(const std::string& env)
|
||||||
{
|
{
|
||||||
std::cout << env << "=" << ::dfi::common::get_env(env) << "\n";
|
std::cout << env << "=" << ::dfi::common::get_env(env) << "\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
void Example::example1()
|
void MyExamples::example1()
|
||||||
{
|
{
|
||||||
using g_Random = dfi::crypto::cryptopp::Random;
|
using g_Random = dfi::crypto::cryptopp::Random;
|
||||||
using g_Hash = dfi::crypto::libsodium::Hash;
|
using g_Hash = dfi::crypto::libsodium::Hash;
|
||||||
@@ -64,21 +66,21 @@ void Example::example1()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Example::example2()
|
void MyExamples::example2()
|
||||||
{
|
{
|
||||||
// Container environment
|
// Container environment
|
||||||
std::cout
|
std::cout
|
||||||
<< "\nShell environment (container)\n-----------------------------\n";
|
<< "\nShell environment (container)\n-----------------------------\n";
|
||||||
Example::print_env("DOCKER_FINANCE_CLIENT_FLOW");
|
MyExamples::print_env("DOCKER_FINANCE_CLIENT_FLOW");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_CMD");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_CMD");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_CONF");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_CONF");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_EDITOR");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_EDITOR");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_FLOW");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_FLOW");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_PLUGINS");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_PLUGINS");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_REPO");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_REPO");
|
||||||
Example::print_env("DOCKER_FINANCE_CONTAINER_SHARED");
|
MyExamples::print_env("DOCKER_FINANCE_CONTAINER_SHARED");
|
||||||
Example::print_env("DOCKER_FINANCE_DEBUG");
|
MyExamples::print_env("DOCKER_FINANCE_DEBUG");
|
||||||
Example::print_env("DOCKER_FINANCE_VERSION");
|
MyExamples::print_env("DOCKER_FINANCE_VERSION");
|
||||||
|
|
||||||
std::cout << "\nSame as previous but executing commands in "
|
std::cout << "\nSame as previous but executing commands in "
|
||||||
"shell\n------------------------------------------------\n";
|
"shell\n------------------------------------------------\n";
|
||||||
@@ -86,35 +88,35 @@ void Example::example2()
|
|||||||
|
|
||||||
// Caller environment
|
// Caller environment
|
||||||
std::cout << "\nShell environment (caller)\n--------------------------\n";
|
std::cout << "\nShell environment (caller)\n--------------------------\n";
|
||||||
Example::print_env("global_arg_delim_1");
|
MyExamples::print_env("global_arg_delim_1");
|
||||||
Example::print_env("global_arg_delim_2");
|
MyExamples::print_env("global_arg_delim_2");
|
||||||
Example::print_env("global_arg_delim_3");
|
MyExamples::print_env("global_arg_delim_3");
|
||||||
Example::print_env("global_arg_subcommand");
|
MyExamples::print_env("global_arg_subcommand");
|
||||||
Example::print_env("global_basename");
|
MyExamples::print_env("global_basename");
|
||||||
Example::print_env("global_child_profile");
|
MyExamples::print_env("global_child_profile");
|
||||||
Example::print_env("global_child_profile_flow");
|
MyExamples::print_env("global_child_profile_flow");
|
||||||
Example::print_env("global_child_profile_journal");
|
MyExamples::print_env("global_child_profile_journal");
|
||||||
Example::print_env("global_conf_fetch");
|
MyExamples::print_env("global_conf_fetch");
|
||||||
Example::print_env("global_conf_hledger");
|
MyExamples::print_env("global_conf_hledger");
|
||||||
Example::print_env("global_conf_meta");
|
MyExamples::print_env("global_conf_meta");
|
||||||
Example::print_env("global_conf_subscript");
|
MyExamples::print_env("global_conf_subscript");
|
||||||
// TODO(unassigned): read array from shell? ROOT impl simply calls stdlib getenv()
|
// TODO(unassigned): read array from shell? ROOT impl simply calls stdlib getenv()
|
||||||
// Example::print_env("global_hledger_cmd");
|
// MyExamples::print_env("global_hledger_cmd");
|
||||||
Example::print_env("global_parent_profile");
|
MyExamples::print_env("global_parent_profile");
|
||||||
Example::print_env("global_usage");
|
MyExamples::print_env("global_usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Example::example3()
|
void MyExamples::example3()
|
||||||
{
|
{
|
||||||
std::cout << "\nImporting journals...\n";
|
std::cout << "\nImporting journals...\n";
|
||||||
Example::exec_cmd("import 1>/dev/null");
|
MyExamples::exec_cmd("import 1>/dev/null");
|
||||||
|
|
||||||
std::cout << "\nShowing BTC balance...\n";
|
std::cout << "\nShowing BTC balance...\n";
|
||||||
Example::exec_cmd("hledger bal assets liabilities cur:BTC");
|
MyExamples::exec_cmd("hledger bal assets liabilities cur:BTC");
|
||||||
|
|
||||||
std::cout << "\nGenerating income tax snippet...\n";
|
std::cout << "\nGenerating income tax snippet...\n";
|
||||||
const std::string delim{::dfi::common::get_env("global_arg_delim_2")};
|
const std::string delim{::dfi::common::get_env("global_arg_delim_2")};
|
||||||
Example::exec_cmd(
|
MyExamples::exec_cmd(
|
||||||
"taxes all" + delim + "account tag" + delim + "income write" + delim
|
"taxes all" + delim + "account tag" + delim + "income write" + delim
|
||||||
+ "off | tail -n3");
|
+ "off | tail -n3");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// docker-finance | modern accounting for the power-user
|
// docker-finance | modern accounting for the power-user
|
||||||
//
|
//
|
||||||
// Copyright (C) 2024-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
// Copyright (C) 2024-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
@@ -37,7 +37,7 @@ namespace dfi::plugin::example
|
|||||||
//!
|
//!
|
||||||
//! \ingroup cpp_plugin_impl
|
//! \ingroup cpp_plugin_impl
|
||||||
//! \since docker-finance 1.1.0
|
//! \since docker-finance 1.1.0
|
||||||
class Example
|
class MyExamples
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! \brief Example plugin function 1
|
//! \brief Example plugin function 1
|
||||||
|
|||||||
Reference in New Issue
Block a user