new features: --devices, --discovery-info, --login-info

```
   --devices             Print the list of devices. All device of this account
                         will be printed, one device per line.
   --discovery-info      Print discovery information about current homeserver.
                         Note that not all homeservers support discovery and an
                         error might be reported.
   --login-info          Print login methods supported by the homeserver. It
                         prints one login method per line.
```

- added --no-sso to documentation for Docker, see Issue #70
pull/76/head
8go 10 months ago
parent 07e5cb793a
commit f616c618bf

2
.gitignore vendored

@ -32,7 +32,7 @@ m_c
/matrix_commander/__pycache__/
# PyPi build files
# leave /dist as it is used by Github PyPi-Publish Workflow
# leave /dist because it is used by Github PyPi-Publish Workflow
versionnumber.txt
/matrix_commander.egg-info/

@ -37,6 +37,9 @@ https://github.com/poljar/matrix-nio)
content repository
- new option `--separator` to customize the column separator in outputs
- new option `--mxc-to-http`
- new option `--devices` to list devices of current user
- new option `--discovery-info` to print discovery info of homeserver
- new option `--login_info` to get the available login methods from the server
# Summary, TLDR
@ -140,6 +143,9 @@ Please give it a :star: on Github right now so others find it more easily.
- Supports getting and setting display name
- Supports getting and setting presence
- Uploading and downloading to/from resource depository
- Listing your devices
- Listing discovery info
- Listing available login methods supported by server
- Supports skipping SSL verification to use HTTP instead of HTTPS
- Supports providing local SSL certificate files
- Supports notification via OS of received messages
@ -486,7 +492,10 @@ $ matrix-commander -m "{title: \"${TITLE}\", message: \"${MSG}\"}"
$ matrix-commander -m "Don't do this"
$ matrix-commander -m 'He said "No" to me.'
$ matrix-commander --separator " || " # customize column separator in outputs
$ matrix-commander --mxc-to-http mac://example.com/abc... # get HTTP
$ matrix-commander --mxc-to-http mxc://example.com/abc... # get HTTP
$ matrix-commander --devices # to list devices of matrix-commander
$ matrix-commander --discovery-info # print discovery info of homeserver
$ matrix-commander --login-info # list login methods
$ # example of how to use stdin, how to pipe data into the program
$ echo "Some text" | matrix-commander # send a text msg via pipe
$ echo "Some text" | matrix-commander -m - # long form to send text via pipe
@ -542,6 +551,7 @@ usage: matrix_commander.py [-h] [-d] [--log-level LOG_LEVEL [LOG_LEVEL ...]]
[--download DOWNLOAD] [--joined-rooms]
[--joined-members JOINED_MEMBERS [JOINED_MEMBERS ...]]
[--mxc-to-http MXC_TO_HTTP [MXC_TO_HTTP ...]]
[--devices] [--discovery-info] [--login-info]
[--whoami] [--no-ssl]
[--ssl-certificate SSL_CERTIFICATE] [--no-sso]
[--file-name FILE_NAME] [--key-dict KEY_DICT]
@ -950,6 +960,13 @@ options:
corresponding HTTP URLs. The MXC URIs to provide look
something like this
'mxc://example.com/SomeStrangeUriKey'.
--devices Print the list of devices. All device of this account
will be printed, one device per line.
--discovery-info Print discovery information about current homeserver.
Note that not all homeservers support discovery and an
error might be reported.
--login-info Print login methods supported by the homeserver. It
prints one login method per line.
--whoami Print the user id used by matrix-commander (itself).
One can get this information also by looking at the
credentials file.
@ -1010,7 +1027,7 @@ options:
information program will continue to run. This is
useful for having version number in the log files.
You are running version 2.27.0 2022-06-03. Enjoy, star on Github and
You are running version 2.28.0 2022-06-03. Enjoy, star on Github and
contribute by submitting a Pull Request.
```

@ -1 +1 @@
2.27.0
2.28.0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -12,6 +12,9 @@ Download/update your local image pulling it by doing:
docker pull matrixcommander/matrix-commander
```
When using Docker, it is recommended to use the `--no-sso` flag because
there is no browser available to perform web-based Single Sign-On.
= matrix-commander with Docker
NOTE: In the following docker commands, the option `:z` is here to make sure that the commands work in systems that use SELinux (eg. Fedora).
@ -43,7 +46,7 @@ This folder must be provided to further `run` commands using the `/data` mountpo
Run this command to initialize the `matrix-commander` data folder with new credentials you must answer all the questions that will pop up interactively (homeserver, username, etc.):
```
docker run --rm -ti -v /my/chosen/folder:/data:z matrix-commander
docker run --rm -ti -v /my/chosen/folder:/data:z matrix-commander --no-ssl
```
You can now use this data folder to send messages or verify your session.

@ -44,6 +44,9 @@ https://github.com/poljar/matrix-nio)
content repository
- new option `--separator` to customize the column separator in outputs
- new option `--mxc-to-http`
- new option `--devices` to list devices of current user
- new option `--discovery-info` to print discovery info of homeserver
- new option `--login_info` to get the available login methods from the server
# Summary, TLDR
@ -147,6 +150,9 @@ Please give it a :star: on Github right now so others find it more easily.
- Supports getting and setting display name
- Supports getting and setting presence
- Uploading and downloading to/from resource depository
- Listing your devices
- Listing discovery info
- Listing available login methods supported by server
- Supports skipping SSL verification to use HTTP instead of HTTPS
- Supports providing local SSL certificate files
- Supports notification via OS of received messages
@ -493,7 +499,10 @@ $ matrix-commander -m "{title: \"${TITLE}\", message: \"${MSG}\"}"
$ matrix-commander -m "Don't do this"
$ matrix-commander -m 'He said "No" to me.'
$ matrix-commander --separator " || " # customize column separator in outputs
$ matrix-commander --mxc-to-http mac://example.com/abc... # get HTTP
$ matrix-commander --mxc-to-http mxc://example.com/abc... # get HTTP
$ matrix-commander --devices # to list devices of matrix-commander
$ matrix-commander --discovery-info # print discovery info of homeserver
$ matrix-commander --login-info # list login methods
$ # example of how to use stdin, how to pipe data into the program
$ echo "Some text" | matrix-commander # send a text msg via pipe
$ echo "Some text" | matrix-commander -m - # long form to send text via pipe
@ -549,6 +558,7 @@ usage: matrix_commander.py [-h] [-d] [--log-level LOG_LEVEL [LOG_LEVEL ...]]
[--download DOWNLOAD] [--joined-rooms]
[--joined-members JOINED_MEMBERS [JOINED_MEMBERS ...]]
[--mxc-to-http MXC_TO_HTTP [MXC_TO_HTTP ...]]
[--devices] [--discovery-info] [--login-info]
[--whoami] [--no-ssl]
[--ssl-certificate SSL_CERTIFICATE] [--no-sso]
[--file-name FILE_NAME] [--key-dict KEY_DICT]
@ -957,6 +967,13 @@ options:
corresponding HTTP URLs. The MXC URIs to provide look
something like this
'mxc://example.com/SomeStrangeUriKey'.
--devices Print the list of devices. All device of this account
will be printed, one device per line.
--discovery-info Print discovery information about current homeserver.
Note that not all homeservers support discovery and an
error might be reported.
--login-info Print login methods supported by the homeserver. It
prints one login method per line.
--whoami Print the user id used by matrix-commander (itself).
One can get this information also by looking at the
credentials file.
@ -1017,7 +1034,7 @@ options:
information program will continue to run. This is
useful for having version number in the log files.
You are running version 2.27.0 2022-06-03. Enjoy, star on Github and
You are running version 2.28.0 2022-06-03. Enjoy, star on Github and
contribute by submitting a Pull Request.
```
@ -1121,11 +1138,12 @@ import magic
import pkg_resources
from aiohttp import ClientConnectorError, ClientSession, TCPConnector, web
from markdown import markdown
from nio import (AsyncClient, AsyncClientConfig, DownloadError,
EnableEncryptionBuilder, JoinedMembersError, JoinedRoomsError,
JoinError, KeyVerificationCancel, KeyVerificationEvent,
from nio import (AsyncClient, AsyncClientConfig, DevicesError,
DiscoveryInfoError, DownloadError, EnableEncryptionBuilder,
JoinedMembersError, JoinedRoomsError, JoinError,
KeyVerificationCancel, KeyVerificationEvent,
KeyVerificationKey, KeyVerificationMac, KeyVerificationStart,
LocalProtocolError, LoginResponse, MatrixRoom,
LocalProtocolError, LoginInfoError, LoginResponse, MatrixRoom,
MessageDirection, PresenceGetError, PresenceSetError,
ProfileGetAvatarResponse, ProfileGetDisplayNameError,
ProfileSetDisplayNameError, RedactedEvent, RedactionEvent,
@ -1152,7 +1170,7 @@ except ImportError:
# version number
VERSION = "2022-06-03"
VERSIONNR = "2.27.0"
VERSIONNR = "2.28.0"
# matrix-commander; for backwards compitability replace _ with -
PROG_WITHOUT_EXT = os.path.splitext(os.path.basename(__file__))[0].replace(
"_", "-"
@ -4209,6 +4227,38 @@ async def action_mxc_to_http(client: AsyncClient, credentials: dict) -> None:
print(f"{mxc}{SEP}{http}")
async def action_devices(client: AsyncClient, credentials: dict) -> None:
"""List devices of account while already logged in."""
resp = await client.devices()
if isinstance(resp, DevicesError):
gs.log.error(f"devices failed with {resp}")
else:
gs.log.debug(f"devices successful with {resp}")
print(*resp.devices, sep="\n") # one per line
async def action_discovery_info(
client: AsyncClient, credentials: dict
) -> None:
"""List discovery_info of home server while already logged in."""
resp = await client.discovery_info()
if isinstance(resp, DiscoveryInfoError):
gs.log.error(f"discovery_info failed with {resp}")
else:
gs.log.debug(f"discovery_info successful with {resp}")
print(resp)
async def action_login_info(client: AsyncClient, credentials: dict) -> None:
"""List login methods of home server while already logged in."""
resp = await client.login_info()
if isinstance(resp, LoginInfoError):
gs.log.error(f"login_info failed with {resp}")
else:
gs.log.debug(f"login_info successful with {resp}")
print(*resp.flows, sep="\n") # one per line
async def action_whoami(client: AsyncClient, credentials: dict) -> None:
"""Get user id while already logged in."""
whoami = credentials["user_id"]
@ -4281,6 +4331,12 @@ async def main_roomsetget_action() -> None:
await action_joined_members(client, credentials)
if gs.pa.mxc_to_http:
await action_mxc_to_http(client, credentials)
if gs.pa.devices:
await action_devices(client, credentials)
if gs.pa.discovery_info:
await action_discovery_info(client, credentials)
if gs.pa.login_info:
await action_login_info(client, credentials)
if gs.pa.whoami:
await action_whoami(client, credentials)
if gs.setget_action:
@ -4519,6 +4575,9 @@ def initial_check_of_args() -> None: # noqa: C901
or gs.pa.joined_rooms
or gs.pa.joined_members
or gs.pa.mxc_to_http
or gs.pa.devices
or gs.pa.discovery_info
or gs.pa.login_info
or gs.pa.whoami
):
gs.setget_action = True
@ -5500,6 +5559,31 @@ def main(
"to provide look something like this "
"'mxc://example.com/SomeStrangeUriKey'.",
)
ap.add_argument(
# no single char flag
"--devices",
required=False,
action="store_true",
help="Print the list of devices. All device of this "
"account will be printed, one device per line.",
)
ap.add_argument(
# no single char flag
"--discovery-info",
required=False,
action="store_true",
help="Print discovery information about current homeserver. "
"Note that not all homeservers support discovery and an error "
"might be reported.",
)
ap.add_argument(
# no single char flag
"--login-info",
required=False,
action="store_true",
help="Print login methods supported by the homeserver. "
"It prints one login method per line.",
)
ap.add_argument(
# no single char flag
"--whoami",

@ -2,7 +2,7 @@
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
# https://setuptools.pypa.io/en/latest/userguide/
name = matrix-commander
version = 2.27.0
version = 2.28.0
author = 8go
description = A simple command-line Matrix client
long_description = file: PyPi-Instructions.md, README.md

Loading…
Cancel
Save