#include <common/args.h>
#include <chainparamsbase.h>
#include <common/settings.h>
#include <logging.h>
#include <sync.h>
#include <tinyformat.h>
#include <univalue.h>
#include <util/chaintype.h>
#include <util/check.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <map>
#include <optional>
#include <stdexcept>
#include <string>
#include <utility>
#include <variant>
Go to the source code of this file.
|
static bool | InterpretBool (const std::string &strValue) |
| Interpret a string argument as a boolean. More...
|
|
static std::string | SettingName (const std::string &arg) |
|
KeyInfo | InterpretKey (std::string key) |
| Parse "name", "section.name", "noname", "section.noname" settings keys. More...
|
|
std::optional< common::SettingsValue > | InterpretValue (const KeyInfo &key, const std::string *value, unsigned int flags, std::string &error) |
| Interpret settings value based on registered flags. More...
|
|
static void | SaveErrors (const std::vector< std::string > errors, std::vector< std::string > *error_out) |
|
std::optional< std::string > | SettingToString (const common::SettingsValue &value) |
|
std::string | SettingToString (const common::SettingsValue &value, const std::string &strDefault) |
|
std::optional< int64_t > | SettingToInt (const common::SettingsValue &value) |
|
int64_t | SettingToInt (const common::SettingsValue &value, int64_t nDefault) |
|
std::optional< bool > | SettingToBool (const common::SettingsValue &value) |
|
bool | SettingToBool (const common::SettingsValue &value, bool fDefault) |
|
bool | HelpRequested (const ArgsManager &args) |
|
void | SetupHelpOptions (ArgsManager &args) |
| Add help options to the args manager. More...
|
|
std::string | HelpMessageGroup (const std::string &message) |
| Format a string to be used as group of options in help messages. More...
|
|
std::string | HelpMessageOpt (const std::string &option, const std::string &message) |
| Format a string to be used as option description in help messages. More...
|
|
bool | HasTestOption (const ArgsManager &args, const std::string &test_option) |
| Checks if a particular test option is present in -test command-line arg options. More...
|
|
fs::path | GetDefaultDataDir () |
|
bool | CheckDataDirOption (const ArgsManager &args) |
|
◆ CheckDataDirOption()
◆ GetDefaultDataDir()
◆ HasTestOption()
bool HasTestOption |
( |
const ArgsManager & |
args, |
|
|
const std::string & |
test_option |
|
) |
| |
Checks if a particular test option is present in -test command-line arg options.
Definition at line 715 of file args.cpp.
◆ HelpMessageGroup()
std::string HelpMessageGroup |
( |
const std::string & |
message | ) |
|
Format a string to be used as group of options in help messages.
- Parameters
-
message | Group name (e.g. "RPC server options:") |
- Returns
- the formatted string
Definition at line 699 of file args.cpp.
◆ HelpMessageOpt()
std::string HelpMessageOpt |
( |
const std::string & |
option, |
|
|
const std::string & |
message |
|
) |
| |
Format a string to be used as option description in help messages.
- Parameters
-
option | Option message (e.g. "-rpcuser=<user>") |
message | Option description (e.g. "Username for JSON-RPC connections") |
- Returns
- the formatted string
Definition at line 703 of file args.cpp.
◆ HelpRequested()
- Returns
- true if help has been requested via a command-line arg
Definition at line 684 of file args.cpp.
◆ InterpretBool()
static bool InterpretBool |
( |
const std::string & |
strValue | ) |
|
|
static |
Interpret a string argument as a boolean.
The definition of LocaleIndependentAtoi<int>() requires that non-numeric string values like "foo", return 0. This means that if a user unintentionally supplies a non-integer argument here, the return value is always false. This means that -foo=false does what the user probably expects, but -foo=true is well defined but does not do what they probably expected.
The return value of LocaleIndependentAtoi<int>(...) is zero when given input not representable as an int.
For a more extensive discussion of this topic (and a wide range of opinions on the Right Way to change this code), see PR12713.
Definition at line 59 of file args.cpp.
◆ InterpretKey()
KeyInfo InterpretKey |
( |
std::string |
key | ) |
|
Parse "name", "section.name", "noname", "section.noname" settings keys.
- Note
- Where an option was negated can be later checked using the IsArgNegated() method. One use case for this is to have a way to disable options that are not normally boolean (e.g. using -nodebuglogfile to request that debug log output is not sent to any file at all).
Definition at line 79 of file args.cpp.
◆ InterpretValue()
std::optional< common::SettingsValue > InterpretValue |
( |
const KeyInfo & |
key, |
|
|
const std::string * |
value, |
|
|
unsigned int |
flags, |
|
|
std::string & |
error |
|
) |
| |
Interpret settings value based on registered flags.
- Parameters
-
[in] | key | key information to know if key was negated |
[in] | value | string value of setting to be parsed |
[in] | flags | ArgsManager registered argument flags |
[out] | error | Error description if settings value is not valid |
- Returns
- parsed settings value if it is valid, otherwise nullopt accompanied by a descriptive error string
Definition at line 107 of file args.cpp.
◆ SaveErrors()
static void SaveErrors |
( |
const std::vector< std::string > |
errors, |
|
|
std::vector< std::string > * |
error_out |
|
) |
| |
|
static |
◆ SettingName()
static std::string SettingName |
( |
const std::string & |
arg | ) |
|
|
static |
◆ SettingToBool() [1/2]
◆ SettingToBool() [2/2]
◆ SettingToInt() [1/2]
◆ SettingToInt() [2/2]
◆ SettingToString() [1/2]
◆ SettingToString() [2/2]
◆ SetupHelpOptions()
Add help options to the args manager.
Definition at line 689 of file args.cpp.
◆ BITCOIN_CONF_FILENAME
const char* const BITCOIN_CONF_FILENAME = "bitcoin.conf" |
◆ BITCOIN_SETTINGS_FILENAME
const char* const BITCOIN_SETTINGS_FILENAME = "settings.json" |
◆ gArgs
◆ msgIndent
◆ optIndent
◆ screenWidth
const int screenWidth = 79 |
|
static |
◆ TEST_OPTIONS_DOC
const std::vector<std::string> TEST_OPTIONS_DOC |
Initial value:{
"addrman (use deterministic addrman)",
"bip94 (enforce BIP94 consensus rules)",
}
Definition at line 710 of file args.cpp.