Skip to content

Commit ece5717

Browse files
authored
[Collections] Documentation: add more details on the CLI (#3379)
- Add table of contents - Document all CLI command options
1 parent d43129a commit ece5717

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

Documentation/PackageCollections.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ Package collections, introduced by [SE-0291](https://github.com/apple/swift-evol
44
curated lists of packages and associated metadata that make discovery of existing packages easier. They are authored as static JSON documents
55
and can be published to the web or distributed to local file systems.
66

7+
## Table of Contents
8+
9+
- [Using package collections with the `package-collection` CLI](#using-package-collections)
10+
- [`add` subcommand](#add-subcommand)
11+
- [Add signed package collections](#signed-package-collections)
12+
- [Configure trusted root certificates](#trusted-root-certificates)
13+
- [Add unsigned package collections](#unsigned-package-collections)
14+
- [`describe` subcommand](#describe-subcommand)
15+
- [Describe a package collection](#metadata-and-packages-of-a-collection)
16+
- [Describe a package](#metadata-of-a-package)
17+
- [Describe a package version](#metadata-of-a-package-version)
18+
- [`list` subcommand](#list-subcommand)
19+
- [`refresh` subcommand](#refresh-subcommand)
20+
- [`remove` subcommand](#remove-subcommand)
21+
- [`search` subcommand](#search-subcommand)
22+
- [Keyword search](#string-based-search)
23+
- [Module search](#module-based-search)
24+
- [Package collection configuration](#configuration-file)
25+
- [Publishing package collections](#publishing-package-collections)
26+
- [Creating package collections](#creating-package-collections)
27+
- [Signing package collections](#package-collection-signing-optional)
28+
- [Protecting package collections](#protecting-package-collections)
29+
730
## Using package collections
831

932
With the `swift package-collection` command-line interface, SwiftPM users can subscribe to package collections. Contents of imported package
@@ -33,6 +56,13 @@ $ swift package-collection add file:///absolute/path/to/packages.json
3356
Added "Sample Package Collection" to your package collections.
3457
```
3558

59+
The optional `order` hint can be used to order collections and may potentially influence ranking in search results:
60+
61+
```bash
62+
$ swift package-collection add https://www.example.com/packages.json [--order N]
63+
Added "Sample Package Collection" to your package collections.
64+
```
65+
3666
#### Signed package collections
3767

3868
Package collection publishers may sign a collection to protect its contents from being tampered with. If a collection is signed, SwiftPM will check that the
@@ -99,14 +129,15 @@ The `--skip-signature-check` flag has no effects on unsigned collections.
99129
100130
### `describe` subcommand
101131
102-
This subcommand shows metadata for a collection or a package included in an imported collection.
132+
This subcommand shows metadata for a collection or a package included in an imported collection. The result can optionally be returned as JSON using `--json` for
133+
integration into other tools.
103134
104135
#### Metadata and packages of a collection
105136
106137
`describe` can be used for both collections that have been previously added to the list of the user's configured collections, as well as to preview any other collections.
107138
108139
```bash
109-
$ swift package-collection describe https://www.example.com/packages.json
140+
$ swift package-collection describe [--json] https://www.example.com/packages.json
110141
Name: Sample Package Collection
111142
Source: https://www.example.com/packages.json
112143
Description: ...
@@ -119,10 +150,10 @@ Packages:
119150
120151
#### Metadata of a package
121152
122-
`describe` shows the metadata of a package included in an imported collection:
153+
`describe` can also show the metadata of a package included in an imported collection:
123154
124155
```bash
125-
$ swift package-collection describe https://github.com/jpsim/yams
156+
$ swift package-collection describe [--json] https://github.com/jpsim/yams
126157
Description: A sweet and swifty YAML parser built on LibYAML.
127158
Available Versions: 4.0.0, 3.0.0, ...
128159
Watchers: 14
@@ -137,12 +168,12 @@ Supported Swift Versions: 5.3, 5.2, 5.1, 5.0
137168
License: MIT
138169
```
139170
140-
#### Metadata for a package version
171+
#### Metadata of a package version
141172
142173
User may view additional metadata for a package version by passing `--version`:
143174
144175
```bash
145-
$ swift package-collection describe --version 4.0.0 https://github.com/jpsim/yams
176+
$ swift package-collection describe [--json] --version 4.0.0 https://github.com/jpsim/yams
146177
Package Name: Yams
147178
Version: 4.0.0
148179
Modules: Yams, CYaml
@@ -156,11 +187,13 @@ License: MIT
156187
This subcommand lists all collections that are configured by the user:
157188
158189
```bash
159-
$ swift package-collection list
190+
$ swift package-collection list [--json]
160191
Sample Package Collection - https://example.com/packages.json
161192
...
162193
```
163194
195+
The result can optionally be returned as JSON using `--json` for integration into other tools.
196+
164197
### `refresh` subcommand
165198
166199
This subcommand refreshes any cached data manually:
@@ -174,7 +207,7 @@ SwiftPM will also automatically refresh data under various conditions, but some
174207
175208
### `remove` subcommand
176209
177-
This subcommand removes as collection from the user's list of configured collections:
210+
This subcommand removes a collection from the user's list of configured collections:
178211
179212
```bash
180213
$ swift package-collection remove https://www.example.com/packages.json
@@ -183,14 +216,15 @@ Removed "Sample Package Collection" from your package collections.
183216
184217
### `search` subcommand
185218
186-
This subcommand searches for packages by keywords or module names within imported collections.
219+
This subcommand searches for packages by keywords or module names within imported collections. The result can optionally be returned as JSON using `--json` for
220+
integration into other tools.
187221
188222
#### String-based search
189223
190224
The search command does a string-based search when using the `--keywords` option and returns the list of packages that matches the query:
191225
192226
```bash
193-
$ swift package-collection search --keywords yaml
227+
$ swift package-collection search [--json] --keywords yaml
194228
https://github.com/jpsim/yams: A sweet and swifty YAML parser built on LibYAML.
195229
...
196230
```
@@ -200,7 +234,7 @@ https://github.com/jpsim/yams: A sweet and swifty YAML parser built on LibYAML.
200234
The search command does a search for a specific module name when using the `--module` option:
201235
202236
```bash
203-
$ swift package-collection search --module yams
237+
$ swift package-collection search [--json] --module yams
204238
Package Name: Yams
205239
Latest Version: 4.0.0
206240
Description: A sweet and swifty YAML parser built on LibYAML.

0 commit comments

Comments
 (0)