nixd
Loading...
Searching...
No Matches
CommandLine/Configuration.cpp
Go to the documentation of this file.
1/// \file
2/// \brief This file implements CLI initialized configuration.
3
7#include "nixd/Support/JSON.h"
8
9#include <llvm/Support/CommandLine.h>
10#include <llvm/Support/JSON.h>
11
12#include <string>
13
14using namespace nixd;
15using namespace llvm::cl;
16
17namespace {
18
19opt<std::string> DefaultConfigJSON{"config",
20 desc("JSON-encoded initial configuration"),
21 init(""), cat(NixdCategory)};
22
23} // namespace
24
26 if (DefaultConfigJSON.empty())
27 return {};
28
29 return nixd::fromJSON<Configuration>(nixd::parse(DefaultConfigJSON));
30}
Allow default configuration being passed via CLI.
Declares workspace configuration schema.
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::cl::OptionCategory NixdCategory
nixd::Configuration parseCLIConfig()
Parse the CLI flag and initialize the config nixd::DefaultConfig.
llvm::json::Value parse(llvm::StringRef JSON)
Definition JSON.cpp:5