Skip to content

Commit c6191e4

Browse files
committed
Document CLI discovery and storage commands
1 parent 3cf5f13 commit c6191e4

5 files changed

Lines changed: 133 additions & 10 deletions

File tree

README.md

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22

33
CLI client for [Daptin](https://github.com/daptin/daptin) — the headless CMS and API server.
44

5-
All Daptin entities are accessed uniformly via CRUD commands. All Daptin actions (signin, signup, upload, export, etc.) are executed uniformly via `execute`. No special-case commands.
5+
All Daptin entities are accessed uniformly via CRUD commands, and all Daptin actions can be executed uniformly via `execute`. Common workflows such as cloud storage and file asset uploads also have ergonomic wrapper commands.
6+
7+
## Discovery
8+
9+
The CLI is self-describing. Start with:
10+
11+
```bash
12+
daptin-cli --help
13+
daptin-cli list --help
14+
daptin-cli execute --help
15+
daptin-cli describe action --help
16+
daptin-cli storage --help
17+
daptin-cli asset --help
18+
```
19+
20+
For any Daptin action, use `describe action` before `execute` to see whether the action needs an instance reference id and which input fields it accepts:
21+
22+
```bash
23+
daptin-cli describe action integration install_integration
24+
daptin-cli execute integration install_integration --reference-id <integration_reference_id>
25+
```
626

727
## Install
828

@@ -50,14 +70,17 @@ Grab a binary from the [releases page](https://github.com/daptin/daptin-cli/rele
5070
daptin-cli context add myserver http://localhost:6336
5171
daptin-cli context set myserver
5272

53-
# Sign in (signin is just an action like any other)
73+
# Sign in (signin is an action like any other)
5474
daptin-cli execute user_account signin email=admin@example.com password=secret
5575

5676
# List tables
5777
daptin-cli list --columns table_name,is_top_level world
5878

5979
# List rows
6080
daptin-cli list --columns name,email --page-size 20 user_account
81+
82+
# Discover action requirements
83+
daptin-cli describe action integration install_integration
6184
```
6285

6386
## Context Management
@@ -95,6 +118,7 @@ daptin-cli list --columns table_name,reference_id --page-size 50 world
95118
daptin-cli list --sort -created_at --page-size 10 document
96119

97120
# Filter
121+
daptin-cli list --filter name=administrators usergroup
98122
daptin-cli list --filter "status is active" task
99123
daptin-cli list --filter "table_name like %doc%" world
100124
daptin-cli list --filter "name is admin;email contains example" user_account
@@ -139,7 +163,7 @@ daptin-cli related document <ref_id> user_account_id
139163

140164
## Actions
141165

142-
All Daptin actions — built-in or custom — are executed with `execute`. There are no special commands for signin, signup, upload, etc.
166+
All Daptin actions — built-in or custom — can be executed with `execute`.
143167

144168
```bash
145169
daptin-cli execute <entity> <action_name> [key=val ...]
@@ -196,6 +220,12 @@ For actions that require an entity instance, pass `--reference-id`:
196220
daptin-cli execute cloud_store upload_file --reference-id <cloud_store_id> path=/docs
197221
```
198222

223+
Use `describe action` when you are unsure:
224+
225+
```bash
226+
daptin-cli describe action cloud_store upload_file
227+
```
228+
199229
## Describe
200230

201231
### Table schema
@@ -212,7 +242,54 @@ Shows columns (name + type) and available actions.
212242
daptin-cli describe action document createDocument
213243
```
214244

215-
Shows the action's InFields (the parameters it accepts).
245+
Shows whether the action is instance-bound, whether `--reference-id` is required, the action's InFields, and an example `execute` command.
246+
247+
## Storage
248+
249+
Cloud storage setup and common file operations are available through `storage`.
250+
251+
```bash
252+
# Create a local store
253+
daptin-cli storage add local-files \
254+
--type local \
255+
--store-provider local \
256+
--root-path /tmp/daptin-files
257+
258+
# Create an S3/MinIO-style store and linked credential
259+
daptin-cli storage add minio \
260+
--type s3 \
261+
--provider Minio \
262+
--endpoint http://localhost:9000 \
263+
--access-key minioadmin \
264+
--secret-key minioadmin123 \
265+
--bucket daptin-test \
266+
--restart
267+
268+
# List and remove stores
269+
daptin-cli storage list
270+
daptin-cli storage remove minio
271+
```
272+
273+
File operations use `store-name:/path` addressing:
274+
275+
```bash
276+
daptin-cli storage mkdir local-files:/photos
277+
daptin-cli storage upload local-files:/photos ./image.jpg
278+
daptin-cli storage upload local-files:/site ./public --recursive
279+
daptin-cli storage mv local-files:/photos/image.jpg local-files:/archive/image.jpg
280+
daptin-cli storage rm local-files:/archive/image.jpg
281+
```
282+
283+
Direct `storage ls` and `storage download` for `cloud_store` paths are intentionally not implemented as direct cloud-store commands because Daptin exposes those flows through site file actions and asset routes, not direct `cloud_store` actions.
284+
285+
## Asset Columns
286+
287+
Use `asset` for `file.*` columns on normal entity rows. These commands use Daptin's `/asset/...` routes.
288+
289+
```bash
290+
daptin-cli asset upload product <product_reference_id> photo ./image.jpg
291+
daptin-cli asset list product <product_reference_id> photo
292+
```
216293

217294
## Output
218295

@@ -225,9 +302,10 @@ daptin-cli --output json list world
225302

226303
## Filter Syntax
227304

228-
Filters are semicolon-separated `<column> <operator> <value>` expressions:
305+
Filters can use `key=value` shorthand or semicolon-separated `<column> <operator> <value>` expressions:
229306

230307
```bash
308+
--filter "name=alice"
231309
--filter "name is alice"
232310
--filter "status is active;role is admin"
233311
--filter "name like %ali%"

cmd/action.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ import (
1818
func executeCommand(appCtx *AppContext) *cli.Command {
1919
return &cli.Command{
2020
Name: "execute",
21-
Usage: "Execute an action on an entity",
21+
Usage: "Execute a Daptin action on an entity",
2222
ArgsUsage: "<entity> <action_name> [key=val ...]",
23+
UsageText: `daptin execute <entity> <action_name> [key=val ...]
24+
daptin execute user_account signin email=admin@example.com password=secret
25+
daptin execute integration install_integration --reference-id <integration_reference_id>
26+
daptin execute user_account signin --interactive`,
27+
Description: "Use describe action first when you need to know whether an action requires --reference-id or which fields it accepts.",
2328
Flags: []cli.Flag{
2429
&cli.StringFlag{
2530
Name: "reference-id",

cmd/crud.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func listCommand(appCtx *AppContext) *cli.Command {
1717
Name: "list",
1818
Usage: "List rows of an entity",
1919
ArgsUsage: "<entity>",
20+
UsageText: `daptin list <entity> [flags]
21+
daptin list usergroup --filter name=administrators --columns name,reference_id
22+
daptin list world --filter "table_name like %doc%" --page-size 50
23+
daptin list document --sort -created_at`,
2024
Flags: []cli.Flag{
2125
&cli.StringFlag{
2226
Name: "columns",
@@ -38,7 +42,7 @@ func listCommand(appCtx *AppContext) *cli.Command {
3842
},
3943
&cli.StringFlag{
4044
Name: "filter",
41-
Usage: "Filter expression",
45+
Usage: "Filter expression, e.g. name=value or \"name is value\"",
4246
},
4347
&cli.StringFlag{
4448
Name: "include",

cmd/describe.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ func describeCommand(appCtx *AppContext) *cli.Command {
3838
},
3939
{
4040
Name: "action",
41-
Usage: "Show action schema (InFields, OutFields)",
41+
Usage: "Show action schema, fields, and reference-id requirement",
4242
ArgsUsage: "<entity> <action_name>",
43+
UsageText: `daptin describe action <entity> <action_name>
44+
daptin describe action integration install_integration
45+
daptin describe action user_account signin`,
4346
Action: func(c *cli.Context) error {
4447
entityName := c.Args().Get(0)
4548
actionName := c.Args().Get(1)

cmd/storage.go

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func storageCommand(appCtx *AppContext) *cli.Command {
2020
return &cli.Command{
2121
Name: "storage",
2222
Usage: "Manage Daptin cloud stores and storage actions",
23+
UsageText: `daptin storage <command> [options]
24+
daptin storage list
25+
daptin storage add minio --type s3 --provider Minio --endpoint http://localhost:9000 --access-key minioadmin --secret-key minioadmin123 --bucket daptin-test
26+
daptin storage add local-files --type local --store-provider local --root-path /tmp/daptin-files
27+
daptin storage upload local-files:/photos ./image.jpg
28+
daptin storage mkdir local-files:/photos
29+
daptin storage rm local-files:/photos/old.jpg`,
30+
Description: "These commands wrap Daptin's cloud_store records and supported cloud_store actions. Direct cloud_store ls/download are not exposed by Daptin; use site file actions or asset routes for those flows.",
2331
Subcommands: []*cli.Command{
2432
storageAddCommand(appCtx),
2533
storageListCommand(appCtx),
@@ -39,6 +47,10 @@ func storageAddCommand(appCtx *AppContext) *cli.Command {
3947
Name: "add",
4048
Usage: "Create a cloud_store and optional rclone credential",
4149
ArgsUsage: "<name>",
50+
UsageText: `daptin storage add <name> [flags]
51+
daptin storage add minio --type s3 --provider Minio --endpoint http://localhost:9000 --access-key minioadmin --secret-key minioadmin123 --bucket daptin-test
52+
daptin storage add local-files --type local --store-provider local --root-path /tmp/daptin-files
53+
daptin storage add s3-prod --type s3 --provider AWS --bucket prod-bucket --param region=us-east-1 --restart`,
4254
Flags: []cli.Flag{
4355
&cli.StringFlag{Name: "type", Value: "s3", Usage: "Rclone storage type"},
4456
&cli.StringFlag{Name: "provider", Usage: "Rclone credential provider name"},
@@ -132,8 +144,9 @@ func storageAddCommand(appCtx *AppContext) *cli.Command {
132144

133145
func storageListCommand(appCtx *AppContext) *cli.Command {
134146
return &cli.Command{
135-
Name: "list",
136-
Usage: "List configured cloud stores",
147+
Name: "list",
148+
Usage: "List configured cloud stores",
149+
UsageText: `daptin storage list`,
137150
Action: func(c *cli.Context) error {
138151
result, err := appCtx.Client.FindAll("cloud_store", daptinClient.DaptinQueryParameters{"page[size]": 500})
139152
if err != nil {
@@ -150,6 +163,8 @@ func storageRemoveCommand(appCtx *AppContext) *cli.Command {
150163
Name: "remove",
151164
Usage: "Delete a cloud_store by name or reference_id",
152165
ArgsUsage: "<name-or-reference-id>",
166+
UsageText: `daptin storage remove <name-or-reference-id>
167+
daptin storage remove local-files`,
153168
Action: func(c *cli.Context) error {
154169
ref, err := cloudStoreRef(appCtx, c.Args().Get(0))
155170
if err != nil {
@@ -169,6 +184,10 @@ func storageUploadCommand(appCtx *AppContext) *cli.Command {
169184
Name: "upload",
170185
Usage: "Upload a file or recursive directory to cloud_store via upload_file",
171186
ArgsUsage: "<store:/path> <local-path>",
187+
UsageText: `daptin storage upload <store:/path> <local-path>
188+
daptin storage upload local-files:/photos ./image.jpg
189+
daptin storage upload local-files:/docs/ ./manual.pdf
190+
daptin storage upload local-files:/site/ ./public --recursive`,
172191
Flags: []cli.Flag{
173192
&cli.BoolFlag{Name: "recursive", Usage: "Upload a directory recursively"},
174193
},
@@ -198,6 +217,8 @@ func storageMkdirCommand(appCtx *AppContext) *cli.Command {
198217
Name: "mkdir",
199218
Usage: "Create a folder in cloud_store",
200219
ArgsUsage: "<store:/path>",
220+
UsageText: `daptin storage mkdir <store:/path>
221+
daptin storage mkdir local-files:/photos`,
201222
Action: func(c *cli.Context) error {
202223
storeName, targetPath, err := parseStorageAddress(c.Args().Get(0))
203224
if err != nil {
@@ -217,6 +238,8 @@ func storageRemovePathCommand(appCtx *AppContext) *cli.Command {
217238
Name: "rm",
218239
Usage: "Delete a path from cloud_store",
219240
ArgsUsage: "<store:/path>",
241+
UsageText: `daptin storage rm <store:/path>
242+
daptin storage rm local-files:/photos/old.jpg`,
220243
Action: func(c *cli.Context) error {
221244
storeName, targetPath, err := parseStorageAddress(c.Args().Get(0))
222245
if err != nil {
@@ -232,6 +255,8 @@ func storageMoveCommand(appCtx *AppContext) *cli.Command {
232255
Name: "mv",
233256
Usage: "Move or rename a path in the same cloud_store",
234257
ArgsUsage: "<store:/source> <store:/destination>",
258+
UsageText: `daptin storage mv <store:/source> <store:/destination>
259+
daptin storage mv local-files:/old.jpg local-files:/archive/old.jpg`,
235260
Action: func(c *cli.Context) error {
236261
srcStore, source, err := parseStorageAddress(c.Args().Get(0))
237262
if err != nil {
@@ -263,6 +288,10 @@ func assetCommand(appCtx *AppContext) *cli.Command {
263288
return &cli.Command{
264289
Name: "asset",
265290
Usage: "Manage file asset columns",
291+
UsageText: `daptin asset <command> [options]
292+
daptin asset upload product <product_reference_id> photo ./image.jpg
293+
daptin asset list product <product_reference_id> photo`,
294+
Description: "Asset commands use Daptin's /asset routes for file.* columns on normal entity rows.",
266295
Subcommands: []*cli.Command{
267296
assetUploadCommand(appCtx),
268297
assetListCommand(appCtx),
@@ -275,6 +304,8 @@ func assetUploadCommand(appCtx *AppContext) *cli.Command {
275304
Name: "upload",
276305
Usage: "Stream a file into a file.* asset column",
277306
ArgsUsage: "<entity> <reference_id> <column> <local-file>",
307+
UsageText: `daptin asset upload <entity> <reference_id> <column> <local-file>
308+
daptin asset upload product <product_reference_id> photo ./image.jpg`,
278309
Action: func(c *cli.Context) error {
279310
entityName, referenceID, columnName, localPath := c.Args().Get(0), c.Args().Get(1), c.Args().Get(2), c.Args().Get(3)
280311
if entityName == "" || referenceID == "" || columnName == "" || localPath == "" {
@@ -314,6 +345,8 @@ func assetListCommand(appCtx *AppContext) *cli.Command {
314345
Name: "list",
315346
Usage: "List files recorded in a file.* asset column",
316347
ArgsUsage: "<entity> <reference_id> <column>",
348+
UsageText: `daptin asset list <entity> <reference_id> <column>
349+
daptin asset list product <product_reference_id> photo`,
317350
Action: func(c *cli.Context) error {
318351
entityName, referenceID, columnName := c.Args().Get(0), c.Args().Get(1), c.Args().Get(2)
319352
if entityName == "" || referenceID == "" || columnName == "" {

0 commit comments

Comments
 (0)