Skip to content

Commit edec6d8

Browse files
committed
docs(cmd/git): Improve Manager/Command terminology
why: Better describe how Managers enable intuitive traversal of git entities while Commands target specific entities for operations what: - Update Manager docstrings: "Traverse and manage with ORM-like filtering" - Update Cmd docstrings: "Run git commands targeting a specific [entity]" - Revise README Command Abstraction section - Update docs/topics/traversing_git.md overview - Update docs/cmd/git/index.md and docs/cmd/index.md descriptions
1 parent 9e4f632 commit edec6d8

5 files changed

Lines changed: 39 additions & 40 deletions

File tree

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ print(f"Current revision: {repo.get_revision()}")
7676
```
7777

7878
### 2. Command Abstraction
79-
Access the full power of the underlying CLI tools without parsing string output manually.
79+
Traverse repository entities intuitively with ORM-like filtering, then run targeted commands against them.
8080

8181
[**Learn more about Command Abstraction**](https://libvcs.git-pull.com/cmd/)
8282

@@ -87,18 +87,16 @@ from libvcs.cmd.git import Git
8787
# Initialize the wrapper
8888
git = Git(path=pathlib.Path.cwd() / 'libvcs')
8989

90-
# Run commands intuitively
90+
# Run commands directly
9191
git.clone(url='https://github.com/vcs-python/libvcs.git')
9292
git.checkout(ref='master')
9393

94-
# Branch management
94+
# Traverse branches with ORM-like filtering
9595
git.branches.create('feature/new-gui')
96-
print(git.branches.ls()) # List all branches
96+
print(git.branches.ls()) # Returns QueryList for filtering
9797

98-
# Remote management
98+
# Target specific entities with contextual commands
9999
git.remotes.set_url(name='origin', url='git@github.com:vcs-python/libvcs.git')
100-
101-
# Tag management
102100
git.tags.create(name='v1.0.0', message='Release version 1.0.0')
103101
```
104102

docs/cmd/git/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ _Compare to: [`fabtools.git`](https://fabtools.readthedocs.io/en/0.19.0/api/git.
66
[`salt.modules.git`](https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html),
77
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)_
88

9-
## Manager/Cmd Pattern
9+
## Managers and Commands
1010

11-
libvcs provides a **Manager/Cmd pattern** for git subcommands:
11+
libvcs provides **Managers** and **Commands** for git subcommands:
1212

13-
- **Manager** classes (`git.branches`, `git.tags`, etc.) handle collection-level operations
14-
- **Cmd** classes represent individual entities with mutation methods
13+
- **Managers** (`git.branches`, `git.tags`, etc.) let you traverse repository
14+
entities intuitively with ORM-like filtering via QueryList
15+
- **Commands** are contextual ways to run git commands against a specific target entity
1516

1617
```
1718
Git instance

docs/cmd/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ versions.
1717

1818
The `libvcs.cmd` module provides Python wrappers for VCS command-line tools:
1919

20-
- {mod}`libvcs.cmd.git` - Git commands with Manager/Cmd pattern for branches, tags, remotes, etc.
20+
- {mod}`libvcs.cmd.git` - Git commands with Managers for intuitive entity traversal and Commands for targeted execution
2121
- {mod}`libvcs.cmd.hg` - Mercurial commands
2222
- {mod}`libvcs.cmd.svn` - Subversion commands
2323

docs/topics/traversing_git.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
# Traversing Git Repos
44

5-
libvcs provides **Manager** and **Cmd** classes for navigating the "object graph"
6-
of your git repository. These aren't just convenient abstractions—they're also
7-
simulacra of the git commands themselves, giving you typed Python objects instead
8-
of raw strings.
5+
libvcs provides **Managers** and **Commands** for intuitively traversing and
6+
navigating entities in a git repository—branches, tags, remotes, stashes, and
7+
more—with ORM-like convenience via {class}`~libvcs._internal.query_list.QueryList`.
98

109
## Overview
1110

1211
The pattern consists of two types of classes:
1312

14-
- **Manager** classes handle collection-level operations (`ls()`, `get()`,
15-
`filter()`, `add()`/`create()`)
16-
- **Cmd** classes handle per-entity operations (`show()`, `remove()`,
17-
`rename()`)
13+
- **Managers** (`git.branches`, `git.tags`, etc.) let you traverse repository
14+
entities intuitively, listing, filtering, and retrieving them with ORM-like
15+
convenience
16+
- **Commands** are contextual ways to run git commands against a specific target
17+
entity (e.g., delete a branch, rename a tag, set a remote's URL)
1818

1919
```
2020
Git instance
@@ -103,7 +103,7 @@ Cmd objects have methods for mutating or inspecting that entity:
103103

104104
### Before: Parsing Strings
105105

106-
Without the Manager/Cmd pattern, you'd parse raw output:
106+
Without Managers and Commands, you'd parse raw output:
107107

108108
```python
109109
>>> from libvcs.cmd.git import Git
@@ -115,7 +115,7 @@ Without the Manager/Cmd pattern, you'd parse raw output:
115115

116116
### After: Typed Objects
117117

118-
With the Manager/Cmd pattern, you get typed objects:
118+
With Managers and Commands, you get typed objects:
119119

120120
```python
121121
>>> from libvcs.cmd.git import Git

src/libvcs/cmd/git.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ def show_ref(
23842384

23852385

23862386
class GitSubmoduleCmd:
2387-
"""Run submodule commands in a git repository."""
2387+
"""Run git submodule commands (low-level, use GitSubmoduleManager for traversal)."""
23882388

23892389
def __init__(self, *, path: StrPath, cmd: Git | None = None) -> None:
23902390
"""Lite, typed, pythonic wrapper for git-submodule(1).
@@ -2591,7 +2591,7 @@ def initialized(self) -> bool:
25912591

25922592

25932593
class GitSubmoduleEntryCmd:
2594-
"""Run commands directly on a specific git submodule."""
2594+
"""Run git commands targeting a specific submodule."""
25952595

25962596
def __init__(
25972597
self,
@@ -2945,7 +2945,7 @@ def absorbgitdirs(
29452945

29462946

29472947
class GitSubmoduleManager:
2948-
"""Run commands directly related to git submodules of a git repo."""
2948+
"""Traverse and manage git submodules with ORM-like filtering via QueryList."""
29492949

29502950
def __init__(
29512951
self,
@@ -3633,7 +3633,7 @@ def filter(
36333633

36343634

36353635
class GitRemoteCmd:
3636-
"""Run commands directly for a git remote on a git repository."""
3636+
"""Run git commands targeting a specific remote."""
36373637

36383638
remote_name: str
36393639
fetch_url: str | None
@@ -4178,7 +4178,7 @@ def update(
41784178

41794179

41804180
class GitRemoteManager:
4181-
"""Run commands directly related to git remotes of a git repo."""
4181+
"""Traverse and manage git remotes with ORM-like filtering via QueryList."""
41824182

41834183
remote_name: str
41844184

@@ -4474,7 +4474,7 @@ def filter(self, *args: t.Any, **kwargs: t.Any) -> list[GitRemoteCmd]:
44744474

44754475

44764476
class GitStashEntryCmd:
4477-
"""Run commands directly for a git stash entry on a git repository."""
4477+
"""Run git commands targeting a specific stash entry."""
44784478

44794479
index: int
44804480
branch: str | None
@@ -4769,7 +4769,7 @@ def create_branch(
47694769

47704770

47714771
class GitStashCmd:
4772-
"""Run commands directly against a git stash storage for a git repo."""
4772+
"""Run git stash commands (low-level, use GitStashManager for traversal)."""
47734773

47744774
def __init__(self, *, path: StrPath, cmd: Git | None = None) -> None:
47754775
"""Lite, typed, pythonic wrapper for git-stash(1).
@@ -5007,7 +5007,7 @@ def save(
50075007

50085008

50095009
class GitStashManager:
5010-
"""Run commands directly related to git stashes of a git repo."""
5010+
"""Traverse and manage git stashes with ORM-like filtering via QueryList."""
50115011

50125012
def __init__(
50135013
self,
@@ -5290,7 +5290,7 @@ def filter(self, *args: t.Any, **kwargs: t.Any) -> list[GitStashEntryCmd]:
52905290

52915291

52925292
class GitBranchCmd:
5293-
"""Run commands directly against a git branch for a git repo."""
5293+
"""Run git commands targeting a specific branch."""
52945294

52955295
branch_name: str
52965296

@@ -5610,7 +5610,7 @@ def track(
56105610

56115611

56125612
class GitBranchManager:
5613-
"""Run commands directly related to git branches of a git repo."""
5613+
"""Traverse and manage git branches with ORM-like filtering via QueryList."""
56145614

56155615
branch_name: str
56165616

@@ -5869,7 +5869,7 @@ def filter(self, *args: t.Any, **kwargs: t.Any) -> list[GitBranchCmd]:
58695869

58705870

58715871
class GitTagCmd:
5872-
"""Run commands directly for a git tag on a git repository."""
5872+
"""Run git commands targeting a specific tag."""
58735873

58745874
tag_name: str
58755875

@@ -6055,7 +6055,7 @@ def show(
60556055

60566056

60576057
class GitTagManager:
6058-
"""Run commands directly related to git tags of a git repo."""
6058+
"""Traverse and manage git tags with ORM-like filtering via QueryList."""
60596059

60606060
def __init__(
60616061
self,
@@ -6386,7 +6386,7 @@ def filter(self, *args: t.Any, **kwargs: t.Any) -> list[GitTagCmd]:
63866386

63876387

63886388
class GitWorktreeCmd:
6389-
"""Run commands directly against a git worktree entry for a git repo."""
6389+
"""Run git commands targeting a specific worktree."""
63906390

63916391
def __init__(
63926392
self,
@@ -6637,7 +6637,7 @@ def repair(
66376637

66386638

66396639
class GitWorktreeManager:
6640-
"""Run commands directly related to git worktrees of a git repo."""
6640+
"""Traverse and manage git worktrees with ORM-like filtering via QueryList."""
66416641

66426642
def __init__(
66436643
self,
@@ -6975,7 +6975,7 @@ def filter(self, *args: t.Any, **kwargs: t.Any) -> list[GitWorktreeCmd]:
69756975

69766976

69776977
class GitNoteCmd:
6978-
"""Run commands directly against a git note for a git repo."""
6978+
"""Run git commands targeting a specific note."""
69796979

69806980
def __init__(
69816981
self,
@@ -7253,7 +7253,7 @@ def copy(
72537253

72547254

72557255
class GitNotesManager:
7256-
"""Run commands directly related to git notes of a git repo."""
7256+
"""Traverse and manage git notes with ORM-like filtering via QueryList."""
72577257

72587258
def __init__(
72597259
self,
@@ -7639,7 +7639,7 @@ def cmd(self) -> GitReflogEntryCmd:
76397639

76407640

76417641
class GitReflogEntryCmd:
7642-
"""Run commands directly on a specific git reflog entry."""
7642+
"""Run git commands targeting a specific reflog entry."""
76437643

76447644
def __init__(
76457645
self,
@@ -7803,7 +7803,7 @@ def delete(
78037803

78047804

78057805
class GitReflogManager:
7806-
"""Run commands directly related to git reflog of a git repo."""
7806+
"""Traverse and manage git reflog entries with ORM-like filtering via QueryList."""
78077807

78087808
def __init__(
78097809
self,

0 commit comments

Comments
 (0)