Skip to content

Commit

Permalink
two new features added: --media-delete and --media-mxc-to-http
Browse files Browse the repository at this point in the history
  • Loading branch information
8go committed Nov 29, 2022
1 parent 08ee954 commit 64d65f1
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "matrix-commander"
version = "0.1.19"
version = "0.1.20"
edition = "2021"
description = "simple but convenient CLI-based Matrix client app for sending and receiving"
documentation = "https://docs.rs/matrix-commander"
Expand All @@ -27,6 +27,7 @@ tracing-subscriber = "0.3"
tracing = "0.1"
directories = "4.0"
matrix-sdk = { version = "0.6", features = ["markdown", "anyhow"] }
# matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk , features = ["markdown", "anyhow"] }
tokio = { version = "1.22", default-features = false, features = [
"rt-multi-thread",
"macros",
Expand Down
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,22 @@ Options:
using '-'. Furthermore, '-' can only be used once. Upon being stored
in the homeserver's content repository, the data is assigned a Matrix
MXC URI. For each file uploaded successfully, a single line with the
MXC URI will be printed
MXC URI will be printed. The uploaded data will not by encrypted. If
you want to upload encrypted data, encrypt the file before uploading
it
--media-download [<MXC_URI>...]
Download one or multiple files from the homeserver content
repository. You must provide one or multiple Matrix URIs (MXCs) which
are strings like this 'mxc://example.com/SomeStrangeUriKey'. If found
they will be downloaded, decrypted, and stored in local files. If
file names are specified with --file-name the downloads will be saved
with these file names. If --file-name is not specified, then the file
name 'mxc-<mxc-id>' will be used. If a file name in --file-name
contains the placeholder __mxc_id__, it will be replaced with the
mxc-id. If a file name is specified as empty string in --file-name,
then also the name 'mxc-<mxc-id>' will be used. Do not confuse
are strings like this 'mxc://example.com/SomeStrangeUriKey'.
Alternatively, you can just provide the MXC id, i.e. the part after
the last slash. If found they will be downloaded, decrypted, and
stored in local files. If file names are specified with --file-name
the downloads will be saved with these file names. If --file-name is
not specified, then the file name 'mxc-<mxc-id>' will be used. If a
file name in --file-name contains the placeholder __mxc_id__, it will
be replaced with the mxc-id. If a file name is specified as empty
string '' in --file-name, then also the name 'mxc-<mxc-id>' will be
used. Be careful, existing files will be overwritten. Do not confuse
--media-download with --download-media. See --download-media
--mime [<MIME_TYPE>...]
Specify the Mime type of certain input files. Specify '' if the Mime
Expand All @@ -682,6 +686,26 @@ Options:
types are: 'image/jpeg', 'image/png', 'image/gif', 'text/plain', and
'application/pdf'. For a full list see
'https://docs.rs/mime/latest/mime/#constants'
--media-delete [<MXC_URI>...]
Delete one or multiple objects (e.g. files) from the content
repository. You must provide one or multiple Matrix URIs (MXC) which
are strings like this 'mxc://example.com/SomeStrangeUriKey'.
Alternatively, you can just provide the MXC id, i.e. the part after
the last slash. If found they will be deleted from the server
database. In order to delete objects one must have server admin
permissions. Having only room admin permissions is not sufficient and
it will fail. Read
https://matrix-org.github.io/synapse/latest/usage/administration/admin_api/
for learning how to set server admin permissions on the server.
Thumbnails will currently not be deleted. Deleting something that
does not exist will be ignored and will not cause an error
--media-mxc-to-http [<MXC_URI>...]
Convert one or more matrix content URIs to the corresponding HTTP
URLs. The MXC URIs to provide look something like this
'mxc://example.com/SomeStrangeUriKey'. Alternatively, you can just
provide the MXC id, i.e. the part after the last slash. The syntax of
the provided MXC URIs will be verified. The existance of content for
the XMC URI will not be checked
-h, --help
Print help information (use `--help` for more detail)
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.19
0.1.20
42 changes: 33 additions & 9 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,22 @@ Options:
using '-'. Furthermore, '-' can only be used once. Upon being stored
in the homeserver's content repository, the data is assigned a Matrix
MXC URI. For each file uploaded successfully, a single line with the
MXC URI will be printed
MXC URI will be printed. The uploaded data will not by encrypted. If
you want to upload encrypted data, encrypt the file before uploading
it
--media-download [<MXC_URI>...]
Download one or multiple files from the homeserver content
repository. You must provide one or multiple Matrix URIs (MXCs) which
are strings like this 'mxc://example.com/SomeStrangeUriKey'. If found
they will be downloaded, decrypted, and stored in local files. If
file names are specified with --file-name the downloads will be saved
with these file names. If --file-name is not specified, then the file
name 'mxc-<mxc-id>' will be used. If a file name in --file-name
contains the placeholder __mxc_id__, it will be replaced with the
mxc-id. If a file name is specified as empty string in --file-name,
then also the name 'mxc-<mxc-id>' will be used. Do not confuse
are strings like this 'mxc://example.com/SomeStrangeUriKey'.
Alternatively, you can just provide the MXC id, i.e. the part after
the last slash. If found they will be downloaded, decrypted, and
stored in local files. If file names are specified with --file-name
the downloads will be saved with these file names. If --file-name is
not specified, then the file name 'mxc-<mxc-id>' will be used. If a
file name in --file-name contains the placeholder __mxc_id__, it will
be replaced with the mxc-id. If a file name is specified as empty
string '' in --file-name, then also the name 'mxc-<mxc-id>' will be
used. Be careful, existing files will be overwritten. Do not confuse
--media-download with --download-media. See --download-media
--mime [<MIME_TYPE>...]
Specify the Mime type of certain input files. Specify '' if the Mime
Expand All @@ -591,5 +595,25 @@ Options:
types are: 'image/jpeg', 'image/png', 'image/gif', 'text/plain', and
'application/pdf'. For a full list see
'https://docs.rs/mime/latest/mime/#constants'
--media-delete [<MXC_URI>...]
Delete one or multiple objects (e.g. files) from the content
repository. You must provide one or multiple Matrix URIs (MXC) which
are strings like this 'mxc://example.com/SomeStrangeUriKey'.
Alternatively, you can just provide the MXC id, i.e. the part after
the last slash. If found they will be deleted from the server
database. In order to delete objects one must have server admin
permissions. Having only room admin permissions is not sufficient and
it will fail. Read
https://matrix-org.github.io/synapse/latest/usage/administration/admin_api/
for learning how to set server admin permissions on the server.
Thumbnails will currently not be deleted. Deleting something that
does not exist will be ignored and will not cause an error
--media-mxc-to-http [<MXC_URI>...]
Convert one or more matrix content URIs to the corresponding HTTP
URLs. The MXC URIs to provide look something like this
'mxc://example.com/SomeStrangeUriKey'. Alternatively, you can just
provide the MXC id, i.e. the part after the last slash. The syntax of
the provided MXC URIs will be verified. The existance of content for
the XMC URI will not be checked
-h, --help
Print help information (use `--help` for more detail)
Loading

0 comments on commit 64d65f1

Please sign in to comment.