mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
18c93e4ffd
Summary: It looks like clang in mode/win choke on the code otherwise: P143369452. It's definitively not clear to me why. Since fmt::format should pretty much similarly to folly::to<std::string>, just use that instead. Reviewed By: chadaustin, fanzeyi Differential Revision: D23884978 fbshipit-source-id: f4a7e47169c8b78011340ec0a41871c9fa4b7181
75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
/*
|
|
* This file contains helper functions related to parsing edenfs command line
|
|
* arguments and determining the initial Eden configuration and state directory.
|
|
*
|
|
* This enables this logic to be shared by the main edenfs process as well as
|
|
* other helper tools that need to be able to access the Eden state directory
|
|
* and configuration data.
|
|
*/
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include <folly/Conv.h>
|
|
#include <folly/portability/GFlags.h>
|
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
DECLARE_bool(foreground);
|
|
DECLARE_string(configPath);
|
|
DECLARE_string(etcEdenDir);
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
class EdenConfig;
|
|
class UserInfo;
|
|
|
|
PathComponentPiece getDefaultLogFileName();
|
|
AbsolutePath makeDefaultLogDirectory(AbsolutePathPiece edenDir);
|
|
std::string getLogPath(AbsolutePathPiece edenDir);
|
|
|
|
/**
|
|
* Get the EdenConfig object.
|
|
*
|
|
* This processes the command line arguments and config settings to construct
|
|
* the EdenConfig. This also determines the location of the Eden state
|
|
* directory, which can be obtained by calling EdenConfig::getEdenDir().
|
|
* This function will create the Eden state directory on disk if it does not
|
|
* already exist.
|
|
*/
|
|
std::unique_ptr<EdenConfig> getEdenConfig(UserInfo& identity);
|
|
|
|
/**
|
|
* ArgumentError will be thrown by getEdenConfig() for common or expected
|
|
* exceptions when trying to set up the Eden config data. This includes issues
|
|
* like bad command line arguments or errors creating or finding the expected
|
|
* state and config data on disk.
|
|
*
|
|
* The caller of getEdenConfig() should generally catch ArgumentError exceptions
|
|
* and display them nicely to the end user.
|
|
*/
|
|
class ArgumentError : public std::exception {
|
|
public:
|
|
explicit ArgumentError(std::string&& str) : message_(std::move(str)) {}
|
|
|
|
const char* what() const noexcept override {
|
|
return message_.c_str();
|
|
}
|
|
|
|
private:
|
|
std::string message_;
|
|
};
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|