sapling/eden/fs/cli/cmd_util.py
Ratnadeep Joshi 136b03fb92 Changing eden/Eden/edenfs/Edenfs in the help and other user visible texts to EdenFS
Summary: There are a lot of places in user visible text such as command line help  where EdenFS is mentioned as eden/Eden/edenfs/EdenFS. This will make it consistent to 'EdenFS' in most cases. In the places where it is referring to the process/daemon, 'edenfs' will be used.

Reviewed By: chadaustin

Differential Revision: D29419151

fbshipit-source-id: 7b8296f0a0c84fdcb566ff811f7fcedbe7079189
2021-07-06 12:17:20 -07:00

46 lines
1.3 KiB
Python

#!/usr/bin/env python3
# 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.
# pyre-strict
import argparse
import os
from pathlib import Path
from typing import Optional, Tuple, Union
from . import config as config_mod, subcmd as subcmd_mod
from .config import EdenCheckout, EdenInstance
def get_eden_instance(args: argparse.Namespace) -> EdenInstance:
return EdenInstance(
args.config_dir, etc_eden_dir=args.etc_eden_dir, home_dir=args.home_dir
)
def find_checkout(
args: argparse.Namespace, path: Union[Path, str, None]
) -> Tuple[EdenInstance, Optional[EdenCheckout], Optional[Path]]:
if path is None:
path = os.getcwd()
return config_mod.find_eden(
path,
etc_eden_dir=args.etc_eden_dir,
home_dir=args.home_dir,
state_dir=args.config_dir,
)
def require_checkout(
args: argparse.Namespace, path: Union[Path, str, None]
) -> Tuple[EdenInstance, EdenCheckout, Path]:
instance, checkout, rel_path = find_checkout(args, path)
if checkout is None:
msg_path = path if path is not None else os.getcwd()
raise subcmd_mod.CmdError(f"no EdenFS checkout found at {msg_path}\n")
assert rel_path is not None
return instance, checkout, rel_path