diff --git a/src/inq/inq.hpp b/src/inq/inq.hpp index a068a4e3..950713e0 100644 --- a/src/inq/inq.hpp +++ b/src/inq/inq.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/src/interface/status.hpp b/src/interface/status.hpp new file mode 100644 index 00000000..de752286 --- /dev/null +++ b/src/interface/status.hpp @@ -0,0 +1,98 @@ +/* -*- indent-tabs-mode: t -*- */ + +#ifndef INQ__INTERFACE__STATUS +#define INQ__INTERFACE__STATUS + +// Copyright (C) 2019-2024 Lawrence Livermore National Security, LLC., Xavier Andrade, Alfredo A. Correa +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace inq { +namespace interface { + +struct { + + constexpr auto name() const { + return "status"; + } + + constexpr auto one_line() const { + return "Shows the status of the currently simulation"; + } + + constexpr auto help() const { + return R""""( + +The 'status' command +================== + +Prints all the currently defined parameters and available results. + +)""""; + } + + static void status() { + interface::cell.status(); + interface::ions.status(); + interface::species.status(); + interface::kpoints.status(); + interface::electrons.status(); + interface::theory.status(); + interface::ground_state.status(); + interface::results_ground_state.status(); + interface::real_time.status(); + interface::results_real_time.status(); + } + + template + void command(ArgsType const & args, bool quiet) const { + + using utils::str_to; + + if(args.size() == 0) { + status(); + actions::normal_exit(); + } + + if(input::environment::global().comm().root()) actions::error(input::environment::global().comm(), "Invalid syntax in the status command"); + } + +#ifdef INQ_PYTHON_INTERFACE + template + void python_interface(PythonModule & module) const { + module.def("status", &status); + } +#endif + +} const status; + +} +} +#endif + +#ifdef INQ_INTERFACE_STATUS_UNIT_TEST +#undef INQ_INTERFACE_STATUS_UNIT_TEST + +#include + +TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG) { + + using namespace inq; + using namespace Catch::literals; + +} +#endif diff --git a/src/interface/theory.hpp b/src/interface/theory.hpp index e0367a84..0a62059e 100644 --- a/src/interface/theory.hpp +++ b/src/interface/theory.hpp @@ -121,10 +121,14 @@ These are the options available: )""""; } - void operator()() const { + static void status() { auto theo = options::theory::load(".inq/default_theory"); if(input::environment::global().comm().root()) std::cout << theo; } + + void operator()() const { + status(); + } void non_interacting() const{ auto theo = options::theory::load(".inq/default_theory").non_interacting(); diff --git a/src/main/inq.cpp b/src/main/inq.cpp index 0c1d38ad..c67054f3 100644 --- a/src/main/inq.cpp +++ b/src/main/inq.cpp @@ -32,6 +32,7 @@ int main(int argc, char* argv[]) { + interface::item(interface::run) + interface::item(interface::species) + interface::item(interface::spectrum) + + interface::item(interface::status) + interface::item(interface::theory) + interface::item(interface::util); @@ -39,22 +40,6 @@ int main(int argc, char* argv[]) { interface::item(interface::units) + interface::item(interface::results); - if(argc == 1){ - if(comm.root()) { - std::cout << "\n"; - std::cout << "Usage: inq [arguments]\n\n"; - std::cout << "The following commands are available:\n"; - std::cout << interface::list_item("help", "Prints detailed information about other commands"); - std::cout << all_commands.list(); - std::cout << "\n"; - std::cout << "And the following options:\n"; - std::cout << interface::list_item("-q,--quiet", "Run silently, do not print information unless explicitly asked to"); - std::cout << interface::list_item("-d,--debug", "Print debug information (useful for inq developers)"); - std::cout << std::endl; - } - interface::actions::normal_exit(); - } - interface::history_file.add_entry(argc, argv); auto quiet = false; @@ -70,6 +55,11 @@ int main(int argc, char* argv[]) { for(int iarg = 1; iarg < argc; iarg++) { auto arg = std::string(argv[iarg]); + if(arg == "-h" or arg == "--help") { + args = {"help"}; + break; + } + if(arg == "-q" or arg == "--quiet") { quiet = true; continue; @@ -123,7 +113,11 @@ int main(int argc, char* argv[]) { } std::cout << "|" << std::endl; } - + + if(args.size() == 0){ + args = {"status"}; + } + auto command = args[0]; args.erase(args.begin()); @@ -133,10 +127,17 @@ int main(int argc, char* argv[]) { if(args.size() == 0){ if(comm.root()) { std::cout << "\n"; - std::cout << "Usage: inq help \n\n"; - std::cout << "The 'help' command prints detailed information about other inq commands:\n\n"; + std::cout << "Usage: inq [arguments]\n\n"; + std::cout << "The following commands are available:\n"; + std::cout << interface::list_item("help", "Prints detailed information about other commands"); std::cout << all_commands.list(); - std::cout << "\nThere is also some additional help topics you can read:\n\n"; + std::cout << "\n"; + std::cout << "And the following options:\n"; + std::cout << interface::list_item("-h,--help", "Prints this help dialog"); + std::cout << interface::list_item("-q,--quiet", "Run silently, do not print information unless explicitly asked to"); + std::cout << interface::list_item("-d,--debug", "Print debug information (useful for inq developers)"); + std::cout << "\nTo get more information about any command use: inq help \n"; + std::cout << "\nBesides commands, there is also some additional help topics you can read with 'help':\n\n"; std::cout << all_helpers.list(); std::cout << std::endl; } diff --git a/src/options/electrons.hpp b/src/options/electrons.hpp index 545e9c1f..065554c2 100644 --- a/src/options/electrons.hpp +++ b/src/options/electrons.hpp @@ -218,7 +218,7 @@ class electrons { if(not self.spin_.has_value()) out << " *"; out << "\n"; - out << "\n * default values" << std::endl; + out << "\n * default values\n" << std::endl; return out; } diff --git a/src/options/ground_state.hpp b/src/options/ground_state.hpp index 9db2ee82..16393746 100644 --- a/src/options/ground_state.hpp +++ b/src/options/ground_state.hpp @@ -212,7 +212,7 @@ class ground_state { if(not self.mixing_.has_value()) out << " *"; out << "\n"; - out << "\n * default values" << std::endl; + out << "\n * default values\n" << std::endl; return out; } diff --git a/src/options/real_time.hpp b/src/options/real_time.hpp index 6e29e2a1..091d96d6 100644 --- a/src/options/real_time.hpp +++ b/src/options/real_time.hpp @@ -265,7 +265,7 @@ class real_time { if(self.obs_.empty()) out << " *"; out << "\n"; - out << "\n * default values" << std::endl; + out << "\n * default values\n" << std::endl; return out; } diff --git a/src/options/theory.hpp b/src/options/theory.hpp index 0b27aab5..90ae7584 100644 --- a/src/options/theory.hpp +++ b/src/options/theory.hpp @@ -165,13 +165,13 @@ class theory { out << "Theory:\n"; if(not self.hartree_potential() and self.exchange() == XC_NONE and self.correlation() == XC_NONE){ - out << " Non-interacting electrons" << std::endl; + out << " non-interacting electrons\n" << std::endl; return out; } if(self.hartree_potential() and self.exchange() == XC_NONE and self.correlation() == XC_NONE){ - out << " Hartree (with self-interaction)\n\n"; - out << " [1] D. R. Hartree, Math. Proc. Camb. Philos. Soc. 24 1, 111 (1928)" << std::endl; + out << " Hartree (with self-interaction)\n\n"; + out << " [1] D. R. Hartree, Math. Proc. Camb. Philos. Soc. 24 1, 111 (1928)\n" << std::endl; return out; } @@ -190,6 +190,8 @@ class theory { out << " " << c_func.family_name() << " - " << c_func.name() << "\n\n"; out << c_func.references(" ") << "\n"; } + + out << std::endl; return out; } diff --git a/tests/help.sh b/tests/help.sh index 6d3578c1..fb9055f3 100755 --- a/tests/help.sh +++ b/tests/help.sh @@ -5,7 +5,6 @@ set -x #output commands to the terminal #Test the help commands -inq inq help inq help clear inq help cell