Skip to content

Commit

Permalink
Moved the aliases to their own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierandrade committed Nov 14, 2024
1 parent 2be9a5c commit b91b87f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 55 deletions.
89 changes: 89 additions & 0 deletions src/interface/aliases.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* -*- indent-tabs-mode: t -*- */

#ifndef INQ__INTERFACE__ALIASES
#define INQ__INTERFACE__ALIASES

// 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 <unordered_map>

namespace inq {
namespace interface {
auto aliases() {
using namespace std::string_literals;

return std::unordered_map<std::string, std::string>{
{ "atomicnumber"s, "atomic-number"s },
{ "calculator"s, "calc"s },
{ "clean"s, "clear"s },
{ "exactexchange"s, "exact-exchange"s },
{ "extraelectrons"s, "extra-electrons"s },
{ "extrastates"s, "extra-states"s },
{ "filename"s, "file"s },
{ "force"s, "forces"s },
{ "fraction"s, "fractional"s },
{ "freq"s, "frequency"s },
{ "functionals"s, "functional"s },
{ "groundstate"s, "ground-state"s },
{ "gs"s, "ground-state"s },
{ "hartreefock"s, "hartree-fock"s },
{ "kpoint"s, "kpoints"s },
{ "kpoints"s, "kpoints"s },
{ "k-point"s, "kpoints"s },
{ "k-points"s, "kpoints"s },
{ "listsets"s, "list-sets"s },
{ "maxsteps"s, "max-steps"s },
{ "mix"s, "mixing"s },
{ "noncollinear"s, "non-collinear"s },
{ "noninteracting"s, "non-interacting"s },
{ "nonlocal"s, "non-local"s },
{ "observable"s, "observables"s },
{ "perturbation"s, "perturbations"s },
{ "pseudo-potential"s, "pseudo"s },
{ "pseudopotential"s, "pseudo"s },
{ "pseudoset"s, "pseudo-set"s },
{ "realtime"s, "real-time"s },
{ "rt"s, "real-time"s },
{ "result"s, "results"s },
{ "results-ground-state"s, "results ground-state"s },
{ "resultsgroundstate"s, "results ground-state"s },
{ "resultsground-state"s, "results ground-state"s },
{ "results-groundstate"s, "results ground-state"s },
{ "resultsgs"s, "results ground-state"s },
{ "results-gs"s, "results ground-state"s },
{ "results-real-time"s, "results real-time"s },
{ "resultsrealtime"s, "results real-time"s },
{ "resultsreal-time"s, "results real-time"s },
{ "results-realtime"s, "results real-time"s },
{ "resultsrt"s, "results real-time"s },
{ "results-rt"s, "results real-time"s },
{ "grid-shifted"s, "shifted-grid"s },
{ "shiftedgrid"s, "shifted-grid"s },
{ "timestep"s, "time-step"s },
{ "totaltime"s, "total-time"s },
{ "totalsteps"s, "total-steps"s },
{ "tol"s, "tolerance"s },
{ "utils"s, "util"s }
};
}
}
}

#endif

#ifdef INQ_INTERFACE_ALIASES_UNIT_TEST
#undef INQ_INTERFACE_ALIASES_UNIT_TEST

#include <catch2/catch_all.hpp>

TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG) {

using namespace inq;
using namespace Catch::literals;

}
#endif
58 changes: 3 additions & 55 deletions src/main/inq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,13 @@

#include <inq/inq.hpp>
#include <interface/aggregate.hpp>
#include <interface/aliases.hpp>

using namespace inq;

int main(int argc, char* argv[]) {
using namespace std::string_literals;
using interface::operator+;

std::unordered_map<std::string, std::string> aliases = {
{ "atomicnumber"s, "atomic-number"s },
{ "calculator"s, "calc"s },
{ "clean"s, "clear"s },
{ "exactexchange"s, "exact-exchange"s },
{ "extraelectrons"s, "extra-electrons"s },
{ "extrastates"s, "extra-states"s },
{ "filename"s, "file"s },
{ "force"s, "forces"s },
{ "fraction"s, "fractional"s },
{ "freq"s, "frequency"s },
{ "functionals"s, "functional"s },
{ "groundstate"s, "ground-state"s },
{ "gs"s, "ground-state"s },
{ "hartreefock"s, "hartree-fock"s },
{ "kpoint"s, "kpoints"s },
{ "kpoints"s, "kpoints"s },
{ "k-point"s, "kpoints"s },
{ "k-points"s, "kpoints"s },
{ "listsets"s, "list-sets"s },
{ "maxsteps"s, "max-steps"s },
{ "mix"s, "mixing"s },
{ "noncollinear"s, "non-collinear"s },
{ "noninteracting"s, "non-interacting"s },
{ "nonlocal"s, "non-local"s },
{ "observable"s, "observables"s },
{ "perturbation"s, "perturbations"s },
{ "pseudo-potential"s, "pseudo"s },
{ "pseudopotential"s, "pseudo"s },
{ "pseudoset"s, "pseudo-set"s },
{ "realtime"s, "real-time"s },
{ "rt"s, "real-time"s },
{ "result"s, "results"s },
{ "results-ground-state"s, "results ground-state"s },
{ "resultsgroundstate"s, "results ground-state"s },
{ "resultsground-state"s, "results ground-state"s },
{ "results-groundstate"s, "results ground-state"s },
{ "resultsgs"s, "results ground-state"s },
{ "results-gs"s, "results ground-state"s },
{ "results-real-time"s, "results real-time"s },
{ "resultsrealtime"s, "results real-time"s },
{ "resultsreal-time"s, "results real-time"s },
{ "results-realtime"s, "results real-time"s },
{ "resultsrt"s, "results real-time"s },
{ "results-rt"s, "results real-time"s },
{ "grid-shifted"s, "shifted-grid"s },
{ "shiftedgrid"s, "shifted-grid"s },
{ "timestep"s, "time-step"s },
{ "totaltime"s, "total-time"s },
{ "totalsteps"s, "total-steps"s },
{ "tol"s, "tolerance"s },
{ "utils"s, "util"s }
};

auto comm = input::environment::global().comm(); //Initialize MPI

auto all_commands =
Expand Down Expand Up @@ -142,6 +88,8 @@ int main(int argc, char* argv[]) {

arg = uniformize(arg);

auto aliases = interface::aliases();

//process aliases
auto search = aliases.find(arg);
if(search != aliases.end()) arg = search->second;
Expand Down

0 comments on commit b91b87f

Please sign in to comment.