Config and trust command internals¶
vcspull.cli.config implements vcspull config and
vcspull trust — reporting active configuration scopes and
managing the trusted project directory state file.
Configuration scope introspection and project trust for vcspull.
-
vcspull.cli.config.create_config_subparser(parser, scope_parent)¶vcspull.cli.config.create_config_subparser(parser, scope_parent)¶
Create
vcspull configargument subparser.- Parameters:
parser (
argparse.ArgumentParser) – Theconfigcommand parser.scope_parent (
argparse.ArgumentParser) – Shared parent carrying--no-projectand--trust-project, so they parse afterlsas well as beforeconfig.
- Return type:
-
vcspull.cli.config.create_trust_subparser(parser)¶vcspull.cli.config.create_trust_subparser(parser)¶
Create
vcspull trustargument subparser.- Parameters:
parser (
ArgumentParser)- Return type:
-
vcspull.cli.config._plural(count, singular, plural=None)¶vcspull.cli.config._plural(count, singular, plural=None)¶
Return count with a correctly inflected noun.
Examples
>>> _plural(1, "repo") '1 repo' >>> _plural(0, "repo") '0 repos' >>> _plural(2, "repository", "repositories") '2 repositories'
-
vcspull.cli.config._note(declared, effective, *, untrusted)¶vcspull.cli.config._note(declared, effective, *, untrusted)¶
Return the parenthetical explaining why a file’s count is not its whole.
Examples
>>> _note(2, 2, untrusted=False) '' >>> _note(2, 1, untrusted=False) ' (1 overridden)' >>> _note(2, 0, untrusted=True) ' (untrusted)'
-
vcspull.cli.config._declared_repos(path, cwd)¶vcspull.cli.config._declared_repos(path, cwd)¶
Return the destination of every repository a single file declares.
-
class vcspull.cli.config._ScopeRow¶class vcspull.cli.config._ScopeRow¶
Bases:
NamedTupleOne line of
vcspull config ls.
-
vcspull.cli.config.config_ls(*, include_project=True, trust_project=False, cwd=None)¶vcspull.cli.config.config_ls(*, include_project=True, trust_project=False, cwd=None)¶
Print the configuration scopes in effect, weakest first.
Each row is a file, its scope, and how many repositories it declares. A file whose entries are overridden by a nearer one says so, and a project file awaiting trust is listed as untrusted rather than silently dropped — this is the command you reach for when
vcspull listrefuses to load something.- Parameters:
include_project (
bool) – SetFalseto show the stack as--no-projectresolves it.trust_project (
bool) – Treat escaping project configs as trusted, as--trust-projectdoes.cwd (
pathlib.Path,optional) – Working directory. Defaults topathlib.Path.cwd().
- Return type:
-
vcspull.cli.config.trust_command(directory, *, untrust=False, show=False, state_file=None)¶vcspull.cli.config.trust_command(directory, *, untrust=False, show=False, state_file=None)¶
Record, remove, or print trusted project directories.
- Parameters:
directory (
str|None) – Directory to trust or untrust. Defaults to the current directory.untrust (
bool) – Remove the directory instead of adding it.show (
bool) – Print the trusted set and make no change.state_file (
pathlib.Path,optional) – File holding the record. Defaults tovcspull._internal.scopes.trust_state_file().
- Return type:
Examples
>>> state = tmp_path / "trusted" >>> trust_command(None, show=True, state_file=state) no trusted project directories >>> api = tmp_path / "api" >>> api.mkdir() >>> trust_command(str(api), state_file=state) trusted ...api >>> scopes.read_trusted(state) == frozenset({api}) True >>> trust_command(str(api), untrust=True, state_file=state) untrusted ...api >>> scopes.read_trusted(state) frozenset()