Skip to content

Commit 08ee954

Browse files
author
8go
committed
3 new features: --mime, --media-upload and --media-download
1 parent 9cf5ea5 commit 08ee954

File tree

7 files changed

+595
-244
lines changed

7 files changed

+595
-244
lines changed

Cargo.lock

Lines changed: 14 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "matrix-commander"
5-
version = "0.1.18"
5+
version = "0.1.19"
66
edition = "2021"
77
description = "simple but convenient CLI-based Matrix client app for sending and receiving"
88
documentation = "https://docs.rs/matrix-commander"
@@ -35,6 +35,7 @@ atty = "0.2"
3535
mime = "0.3"
3636
mime_guess = "2.0"
3737
update-informer = "0.5"
38+
json = "0.12.4"
3839

3940

4041
[dev-dependencies]

README.md

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ Options:
133133
verbosity will be very high. Verbosity only affects the debug
134134
information. So, if '--debug' is not used then '--verbose' will be
135135
ignored
136-
-c, --credentials <PATH TO FILE>
136+
--plain
137+
Disable encryption for a specific action. By default encryption is
138+
turned on wherever possible. E.g. rooms created will be created by
139+
default with encryption enabled. To turn encryption off for a
140+
specific action use --plain. Currently --plain is supported by
141+
--room-create and --room-dm-create. See also --room-enable-encryption
142+
which sort of does the opossite for rooms
143+
-c, --credentials <PATH_TO_FILE>
137144
Path to a file containing credentials. At login (--login),
138145
information about homeserver, user, room id, etc. will be written to
139146
a credentials file. By default, this file is "credentials.json". On
@@ -142,7 +149,7 @@ Options:
142149
room. If this option is provided, the provided path to a file will be
143150
used as credentials file instead of the default one [default:
144151
/home/user/.local/share/matrix-commander-rs/credentials.json]
145-
-s, --store <PATH TO DIRECTORY>
152+
-s, --store <PATH_TO_DIRECTORY>
146153
Path to a directory to be used as "store" for encrypted messaging.
147154
Since encryption is always enabled, a store is always needed. If this
148155
option is provided, the provided directory name will be used as
@@ -151,7 +158,7 @@ Options:
151158
same device. The store directory can be shared between multiple
152159
different devices and users [default:
153160
/home/user/.local/share/matrix-commander-rs/sledstore/]
154-
--login <LOGIN METHOD>
161+
--login <LOGIN_METHOD>
155162
Login to and authenticate with the Matrix homeserver. This requires
156163
exactly one argument, the login method. Currently two choices are
157164
offered: 'password' and 'SSO'. Provide one of these methods. If you
@@ -173,7 +180,7 @@ Options:
173180
browser. So, don't use SSO on headless homeservers where there is no
174181
browser installed or accessible [default: none] [possible values:
175182
none, password, access-token, sso]
176-
--verify <VERIFICATION METHOD>
183+
--verify <VERIFICATION_METHOD>
177184
Perform verification. By default, no verification is performed.
178185
Verification is currently only offered via Emojis. Hence, specify
179186
'--verify emoji'. If verification is desired, run this program in the
@@ -295,17 +302,20 @@ Options:
295302
of text formatted in MarkDown language. '--code' allows sending of
296303
text as a Code block
297304
-r, --room [<ROOM>...]
298-
Optionally specify one or multiple rooms by room ids. '--room' is
299-
used by various options like '--message', '--file', some variants of
300-
'--listen', '--delete-device', etc. If no '--room' is provided the
301-
default room from the credentials file will be used. If a room is
302-
provided in the '--room' argument, then it will be used instead of
303-
the one from the credentials file. The user must have access to the
304-
specified room in order to send messages to it or listen on the room.
305-
Messages cannot be sent to arbitrary rooms. When specifying the room
306-
id some shells require the exclamation mark to be escaped with a
307-
backslash. Not all listen operations allow setting a room. Read more
308-
under the --listen options and similar
305+
Optionally specify one or multiple rooms via room ids or room
306+
aliases. '--room' is used by various options like '--message',
307+
'--file', some variants of '--listen', '--delete-device', etc. The
308+
default room is provided in the credentials file (specified at
309+
--login with --room-default). If a room (or multiple ones) is (or
310+
are) provided in the --room arguments, then it (or they) will be used
311+
instead of the one from the credentials file. The user must have
312+
access to the specified room in order to send messages there or
313+
listen on the room. Messages cannot be sent to arbitrary rooms. When
314+
specifying the room id some shells require the exclamation mark to be
315+
escaped with a backslash. Not all listen operations allow setting a
316+
room. Read more under the --listen options and similar. Most actions
317+
also support room aliases or local canonical short aliases instead of
318+
room ids. Using a room id is always faster than using a room alias
309319
-f, --file [<FILE>...]
310320
Send one or multiple files (e.g. PDF, DOC, MP4). First files are
311321
sent, then text messages are sent. If you want to feed a file into
@@ -316,7 +326,8 @@ Options:
316326
indirectly a MIME type to the piped data. E.g. if you pipe in a PNG
317327
file, you might want to specify additionally '--file-name image.png'.
318328
As such, the label 'image' will be given to the data and the MIME
319-
type 'png' will be attached to it
329+
type 'png' will be attached to it. Furthermore, '-' can only be used
330+
once
320331
--notice
321332
There are 3 message types for '--message'. Text, Notice, and Emote.
322333
By default, if no command line options are specified, 'Text' will be
@@ -329,7 +340,7 @@ Options:
329340
used. Use '--notice' or '--emote' to set the type to Notice or Emote
330341
respectively. '--notice' allows sending of text as a notice.
331342
'--emote' allows sending of text as an emote
332-
--sync <SYNC TYPE>
343+
--sync <SYNC_TYPE>
333344
This option decides on whether the program synchronizes the state
334345
with the server before a 'send' action. Currently two choices are
335346
offered: 'full' and 'off'. Provide one of these choices. The default
@@ -339,7 +350,7 @@ Options:
339350
before a 'send'. If you have chosen 'off', synchronization will be
340351
skipped entirely before the 'send' which will improve performance [default:
341352
full] [possible values: off, full]
342-
-l, --listen <LISTEN TYPE>
353+
-l, --listen <LISTEN_TYPE>
343354
The '--listen' option takes one argument. There are several choices:
344355
'never', 'once', 'forever', 'tail', and 'all'. By default, --listen
345356
is set to 'never'. So, by default no listening will be done. Set it
@@ -378,7 +389,7 @@ Options:
378389
--whoami
379390
Print the user id used by "matrix-commander-rs" (itself). One can get
380391
this information also by looking at the credentials file
381-
-o, --output <OUTPUT FORMAT>
392+
-o, --output <OUTPUT_FORMAT>
382393
This option decides on how the output is presented. Currently offered
383394
choices are: 'text', 'json', 'json-max', and 'json-spec'. Provide one
384395
of these choices. The default is 'text'. If you want to use the
@@ -636,6 +647,41 @@ Options:
636647
Get the profile of itself, i.e. of the 'matrix-commander-rs' user
637648
account. This is getting both display name and avatar MXC URI in a
638649
call
650+
--media-upload [<FILE>...]
651+
Upload one or multiple files (e.g. PDF, DOC, MP4) to the homeserver
652+
content repository. If you want to feed a file for upload into
653+
"matrix-commander-rs" via a pipe, via stdin, then specify the special
654+
character '-' as stdin indicator. See description of '--message' to
655+
see how the stdin indicator '-' is handled. Use --mime to optionally
656+
specify the MIME type of the file. If you give N arguments to
657+
--media-upload, you can give N arguments to --mime. See --mime. If
658+
you pipe a file into stdin, the MIME type cannot be guessed. It is
659+
hence more recommended that you specify a MIME type via '--mime' when
660+
using '-'. Furthermore, '-' can only be used once. Upon being stored
661+
in the homeserver's content repository, the data is assigned a Matrix
662+
MXC URI. For each file uploaded successfully, a single line with the
663+
MXC URI will be printed
664+
--media-download [<MXC_URI>...]
665+
Download one or multiple files from the homeserver content
666+
repository. You must provide one or multiple Matrix URIs (MXCs) which
667+
are strings like this 'mxc://example.com/SomeStrangeUriKey'. If found
668+
they will be downloaded, decrypted, and stored in local files. If
669+
file names are specified with --file-name the downloads will be saved
670+
with these file names. If --file-name is not specified, then the file
671+
name 'mxc-<mxc-id>' will be used. If a file name in --file-name
672+
contains the placeholder __mxc_id__, it will be replaced with the
673+
mxc-id. If a file name is specified as empty string in --file-name,
674+
then also the name 'mxc-<mxc-id>' will be used. Do not confuse
675+
--media-download with --download-media. See --download-media
676+
--mime [<MIME_TYPE>...]
677+
Specify the Mime type of certain input files. Specify '' if the Mime
678+
type should be guessed based on the filename. If input is from stdin
679+
(i.e. '-' and piped into 'matrix-commander-rs') then Mime type cannot
680+
be guessed. If not specified, and no filename available for guessing
681+
it will default to 'application/octet-stream'. Some example mime
682+
types are: 'image/jpeg', 'image/png', 'image/gif', 'text/plain', and
683+
'application/pdf'. For a full list see
684+
'https://docs.rs/mime/latest/mime/#constants'
639685
-h, --help
640686
Print help information (use `--help` for more detail)
641687
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.18
1+
0.1.19

0 commit comments

Comments
 (0)