Skip to content

Commit 130f3b9

Browse files
committed
docs/cli(docs[fmt-import]): add usage docs for new commands
why: surface import and fmt workflows introduced alongside scanner support. what: - link new cli pages in command toctrees - document manual import, --scan options, and fmt usage - reference new commands from quickstart guidance
1 parent 1534b3f commit 130f3b9

File tree

7 files changed

+162
-1
lines changed

7 files changed

+162
-1
lines changed

docs/api/cli/fmt.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vcspull fmt - `vcspull.cli.fmt`
2+
3+
```{eval-rst}
4+
.. automodule:: vcspull.cli.fmt
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:
8+
```

docs/api/cli/import.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vcspull import - `vcspull.cli._import`
2+
3+
```{eval-rst}
4+
.. automodule:: vcspull.cli._import
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:
8+
```

docs/api/cli/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
:maxdepth: 1
1010
1111
sync
12+
import
13+
fmt
1214
```
1315

1416
## vcspull CLI - `vcspull.cli`

docs/cli/fmt.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
(cli-fmt)=
2+
3+
# vcspull fmt
4+
5+
`vcspull fmt` normalizes configuration files so directory keys and repository
6+
entries stay consistent. By default the formatter prints the proposed changes to
7+
stdout. Apply the updates in place with `--write`.
8+
9+
## Command
10+
11+
```{eval-rst}
12+
.. argparse::
13+
:module: vcspull.cli
14+
:func: create_parser
15+
:prog: vcspull
16+
:path: fmt
17+
:nodescription:
18+
```
19+
20+
## What gets formatted
21+
22+
The formatter performs three main tasks:
23+
24+
- Expands string-only entries into verbose dictionaries using the `repo` key.
25+
- Converts legacy `url` keys to `repo` for consistency with the rest of the
26+
tooling.
27+
- Sorts directory keys and repository names alphabetically to minimize diffs.
28+
29+
For example:
30+
31+
```yaml
32+
~/code/:
33+
libvcs: git+https://github.com/vcspull/libvcs.git
34+
vcspull:
35+
url: git+https://github.com/vcspull/vcspull.git
36+
```
37+
38+
becomes:
39+
40+
```yaml
41+
~/code/:
42+
libvcs:
43+
repo: git+https://github.com/vcspull/libvcs.git
44+
vcspull:
45+
repo: git+https://github.com/vcspull/vcspull.git
46+
```
47+
48+
## Writing changes
49+
50+
Run the formatter in dry-run mode first to preview the adjustments, then add
51+
`--write` (or `-w`) to persist them back to disk:
52+
53+
```console
54+
$ vcspull fmt --config ~/.vcspull.yaml
55+
$ vcspull fmt --config ~/.vcspull.yaml --write
56+
```
57+
58+
Use `--all` to iterate over the default search locations: the current working
59+
directory, `~/.vcspull.*`, and the XDG configuration directory. Each formatted
60+
file is reported individually.
61+
62+
```console
63+
$ vcspull fmt --all --write
64+
```
65+
66+
Pair the formatter with [`vcspull import`](cli-import) after scanning the file
67+
system to keep newly added repositories ordered and normalized.

docs/cli/import.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
(cli-import)=
2+
3+
# vcspull import
4+
5+
The `vcspull import` command registers existing repositories with your vcspull
6+
configuration. You can either provide a single repository name and URL or scan
7+
directories for Git repositories that already live on disk.
8+
9+
## Command
10+
11+
```{eval-rst}
12+
.. argparse::
13+
:module: vcspull.cli
14+
:func: create_parser
15+
:prog: vcspull
16+
:path: import
17+
:nodescription:
18+
```
19+
20+
## Manual import
21+
22+
Provide a repository name and remote URL to append an entry to your
23+
configuration. Use `--path` when you already have a working tree on disk so the
24+
configured base directory matches its location. Override the inferred base
25+
directory with `--dir` when you need a specific configuration key.
26+
27+
```console
28+
$ vcspull import my-lib https://github.com/example/my-lib.git --path ~/code/my-lib
29+
```
30+
31+
With no `-c/--config` flag vcspull looks for the first YAML configuration file
32+
under `~/.config/vcspull/` or the current working directory. When none exist a
33+
new `.vcspull.yaml` is created next to where you run the command.
34+
35+
## Filesystem scanning
36+
37+
`vcspull import --scan` discovers Git repositories that already exist on disk
38+
and writes them to your configuration. The command prompts before adding each
39+
repository, showing the inferred name, directory key, and origin URL (when
40+
available).
41+
42+
```console
43+
$ vcspull import --scan ~/code --recursive
44+
? Add ~/code/vcspull (dir: ~/code/)? [y/N]: y
45+
? Add ~/code/libvcs (dir: ~/code/)? [y/N]: y
46+
```
47+
48+
- `--recursive`/`-r` searches nested directories.
49+
- `--base-dir-key` forces all discovered repositories to use the same base
50+
directory key, overriding the automatically expanded directory.
51+
- `--yes`/`-y` accepts every suggestion, which is useful for unattended
52+
migrations.
53+
54+
When vcspull detects a Git remote named `origin` it records the remote URL in
55+
the configuration. Repositories without a remote are still added, allowing you
56+
to fill the `repo` key later.
57+
58+
## Choosing configuration files
59+
60+
Pass `-c/--config` to import into a specific YAML file:
61+
62+
```console
63+
$ vcspull import --scan ~/company --recursive --config ~/company/.vcspull.yaml
64+
```
65+
66+
Use `--all` with the [`vcspull fmt`](cli-fmt) command after a large scan to keep
67+
configuration entries sorted and normalized.

docs/cli/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
:maxdepth: 1
88
99
sync
10+
import
11+
fmt
1012
```
1113

1214
```{toctree}
@@ -31,5 +33,5 @@ completion
3133
:nodescription:
3234
3335
subparser_name : @replace
34-
See :ref:`cli-sync`
36+
See :ref:`cli-sync`, :ref:`cli-import`, :ref:`cli-fmt`
3537
```

docs/quickstart.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ YAML? Create a `~/.vcspull.yaml` file:
111111
"flask": "git+https://github.com/mitsuhiko/flask.git"
112112
```
113113
114+
Already have repositories cloned locally? Use
115+
`vcspull import --scan ~/code --recursive` to detect existing Git checkouts and
116+
append them to your configuration. See {ref}`cli-import` for more details and
117+
options such as `--base-dir-key` and `--yes` for unattended runs. After editing
118+
or importing, run `vcspull fmt --write` (documented in {ref}`cli-fmt`) to
119+
normalize keys and keep your configuration tidy.
120+
114121
The `git+` in front of the repository URL. Mercurial repositories use
115122
`hg+` and Subversion will use `svn+`. Repo type and address is
116123
specified in [pip vcs url][pip vcs url] format.

0 commit comments

Comments
 (0)