eXist-db / xst

Command line tool to interact with exist-db instances
https://npmjs.com/@existdb/xst
MIT License
17 stars 4 forks source link

Removing files from the collection using patterns #119

Open daliboris opened 1 year ago

daliboris commented 1 year ago

Enhancement

I didn't find an example for deleting a list of files using wildcards in the Readme, and maybe it's not implemented yet.

I tried wildcards in the path: xst remove /db/apps/%project%-data/data/dictionaries/*.xml

I also tried -i parameter of the upload command: xst remove -i "*.xml" /db/apps/%project%-data/data/dictionaries/

Both commands failed.

Alternatives

Only the full name of the document being removed worked: xst remove /db/apps/%project%-data/data/dictionaries/pages_157_159.xml

line-o commented 9 months ago

You are right @daliboris this is not implemented yet. Globbing can only work when the path argument(s) are quoted. At least on linux shells this would otherwise lead to errors because the glob would not match any files on the local filesystem. Therefore --include and --exclude are the safer options.

line-o commented 9 months ago

Remove all JavaScript resources in a collection

xst rm /db/apps/myapp --include "*.js"

Remove all files but JavaScript resources in a collection

xst rm /db/apps/myapp --exclude "*.js"

Remove everything recursively that starts with "temp-" (non-empty collections will not be removed)

xst rm -r /db/apps/myapp --include "temp-*"

This might warrant the addition of a --dry-run option to the rm command due to the damage that one might inflict on a db.