// docker-finance | modern accounting for the power-user
//
// Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
//
// 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
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! \file
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
//! \since docker-finance 1.0.0

#ifndef CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_
#define CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_

#include <initializer_list>
#include <string>

#include "../../common/utility.hh"

//! \namespace dfi
//! \since docker-finance 1.0.0
namespace dfi
{
//! \namespace dfi::macro
//! \brief ROOT macros
//! \since docker-finance 1.0.0
namespace macro
{
//! \namespace dfi::macro::common
//! \brief Shared ROOT macro-related functionality
//! \since docker-finance 1.0.0
namespace common
{
//! \brief Load file by path
//! \ingroup cpp_macro_impl
//! \details
//!   Example:
//!     <br>&emsp; root [0] dfi::macro::load("test/unit.C")<br>
//!
//!   Will load:
//!     <br>&emsp; root/macro/test/unit.C<br>
//!
//! \note  Parent directory is `root/macro`
//! \todo Isolate for macros only (similar to plugins)
void load(const std::string& path)
{
  ::dfi::common::Command::load(path);
}

//! \brief Wrapper to load files by list of paths
//! \ingroup cpp_macro_impl
//! \details
//!   Example:
//!     <br>&emsp; root [0] dfi::macro::load({"test/unit.C", "test/benchmark.C"})<br>
//!
//!   Will load:
//!     <br>&emsp; root/macro/test/unit.C and root/test/benchmark.C<br>
//!
//! \note  Parent directory is `root/macro`
//! \todo Isolate for macros only (similar to plugins)
void load(const std::initializer_list<std::string>& paths)
{
  for (const auto& path : paths)
    ::dfi::common::Command::load(path);
}

//! \deprecated This will be removed in the v2 API; use `dfi::common` namespace instead
//! \todo Remove in 2.0.0
//! \since docker-finance 1.0.0
class Command : public ::dfi::common::Command
{
};

//! \deprecated This will be removed in the v2 API; use `dfi::common` namespace instead
//! \todo Remove in 2.0.0
//! \since docker-finance 1.0.0
std::string get_env(const std::string& var)
{
  return ::dfi::common::get_env(var);
}

//! \deprecated This will be removed in the v2 API; use `dfi::common` namespace instead
//! \todo Remove in 2.0.0
//! \since docker-finance 1.0.0
int exec(const std::string& cmd)
{
  return ::dfi::common::exec(cmd);
}

//! \deprecated This will be removed in the v2 API; use `dfi::common` namespace instead
//! \todo Remove in 2.0.0
//! \since docker-finance 1.0.0
std::string make_timestamp()
{
  return ::dfi::common::make_timestamp();
}
}  // namespace common

//! \brief Convenience wrapper to inner common loader
//! \ref dfi::macro::common::load(const std::string& path)
//! \ingroup cpp_macro
//! \since docker-finance 1.1.0
void load(const std::string& path)
{
  common::load(path);
}
//! \brief Convenience wrapper to inner common loader
//! \ref dfi::macro::common::load(const std::initializer_list<std::string>& paths)
//! \ingroup cpp_macro
//! \since docker-finance 1.1.0
void load(const std::initializer_list<std::string>& paths)
{
  common::load(paths);
}

// TODO(afiore): unload

}  // namespace macro
}  // namespace dfi

#endif  // CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_

// # vim: sw=2 sts=2 si ai et
