Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
cmdopt.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
19#include <string_view>
20#include <optional>
21#include <stdexcept>
22#include <string>
23#include <vector>
24
25namespace shamcmdopt {
26
32 int get_argc();
33
39 char **get_argv();
40
50 void register_opt(std::string name, std::optional<std::string> args, std::string description);
51
59 void init(int argc, char *argv[]);
60
68 bool has_option(const std::string_view &option_name);
69
76 std::string_view get_option(const std::string_view &option_name);
77
81 void print_help();
82
85
92 bool is_help_mode();
93
94} // namespace shamcmdopt
95
96namespace opts {
97 using namespace shamcmdopt;
98}
namespace for cli utilities
Definition ci_env.hpp:19
bool is_help_mode()
Check if the help mode is enabled.
Definition cmdopt.cpp:280
int argc
supplied argc from main
Definition cmdopt.cpp:178
bool has_option(const std::string_view &option_name)
Check if an option is present.
Definition cmdopt.cpp:128
char ** argv
supplied argv from main
Definition cmdopt.cpp:181
std::string_view get_option(const std::string_view &option_name)
Get the value of an option.
Definition cmdopt.cpp:146
std::vector< std::string_view > args
Executable argument list (mapped from argv)
Definition cmdopt.cpp:63
char ** get_argv()
Get the command line arguments.
Definition cmdopt.cpp:203
int get_argc()
Get the number of command line arguments.
Definition cmdopt.cpp:197
void init(int argc, char *argv[])
Initialize the command line option parser. We also process generic options in this call (color detect...
Definition cmdopt.cpp:183
void print_completion_zsh()
print zsh completion script to be sourced
Definition cmdopt.cpp:231
void register_opt(std::string name, std::optional< std::string > args, std::string description)
Register a command line option.
Definition cmdopt.cpp:165
void print_help()
Print the help message.
Definition cmdopt.cpp:210