Skip to content

Commit

Permalink
added --login, re-did internals to allow more parallelism
Browse files Browse the repository at this point in the history
- allows for --login, --verify, --get..., -m, --listen all to be done in the same command.

- allows for ephemeral use: --login, -m in one call and then wipe store and credentials
  (devices will accumulate in this case)

- allows for non-interactive login (and send, and get, and set)

- --verify remains interactive

```

  --login LOGIN         Login to and authenticate with the Matrix homeserver.
                        ***THIS IS NOT YET IMPLEMENTED. PLEASE STAY TUNED.***
                        This requires exactly one argument, the login method.
                        Currently two choices are offered: 'password' and
                        'sso'. Provide one of these methods. If you have
                        chosen 'password', you will authenticate through your
                        account password. You can optionally provide these
                        additional arguments: --homeserver to specify the
                        Matrix homeserver, --user-login to specify the log in
                        user id, --password to specify the password, --device
                        to specify a device name, --room-default to specify a
                        default room for sending/listening. If you have chosen
                        'sso', you will authenticate through Single Sign-On. A
                        web-browser will be started and you authenticate on
                        the webpage. You can optionally provide these
                        additional arguments: --homeserver to specify the
                        Matrix homeserver, --user-login to specify the log in
                        user id, --device to specify a device name, --room-
                        default to specify a default room for
                        sending/listening. See all the extra arguments for
                        further explanations.

  --room-default ROOM_DEFAULT
                        Optionally specify a room as the default room for
                        future actions. If not specified for --login, it will
                        be queried via the keyboard. --login stores the
                        specified room as default room in your credentials
                        file. This option is only used in combination with
                        --login. A default room is needed. Specify a valid
                        room either with --room-default or provide it via
                        keyboard.

  --user-login USER_LOGIN
                        Optional argument to specify the user for --login.
                        This gives the otion to specify the user id for login.
                        For '--login sso' the --user-login is not needed as
                        user id can be obtained from server via SSO. For '--
                        login password', if not provided it will be queried
                        via keyboard. A full user id like '@john:example.com',
                        a partial user name like '@john', and a short user
                        name like 'john' can be given. --user-login is only
                        used by --login and ignored by all other actions.

  --password PASSWORD   Specify a password for use by certain actions. It is
                        an optional argument. By default --password is ignored
                        and not used. It is used by '--login password' and '--
                        delete-device' actions. If not provided for --login
                        the user will be queried via keyboard.
  --homeserver HOMESERVER
                        Specify a homeserver for use by certain actions. It is
                        an optional argument. By default --homeserver is
                        ignored and not used. It is used by '--login' action.
                        If not provided for --login the user will be queried
                        via keyboard.
  --device DEVICE       Specify a device name, for use by certain actions. It
                        is an optional argument. By default --device is
                        ignored and not used. It is used by '--login' action.
                        If not provided for --login the user will be queried
                        via keyboard. If you want the default value specify
                        ''. Multiple devices (with different device id) may
                        have the same device name. In short, the same device
                        name can be assigned to multiple different devices if
                        desired.
```
  • Loading branch information
8go committed Jun 24, 2022
1 parent 7455a7c commit 9a08ecb
Show file tree
Hide file tree
Showing 9 changed files with 1,619 additions and 502 deletions.
336 changes: 215 additions & 121 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.38.0
2.38.1
Binary file removed dist/matrix-commander-2.38.0.tar.gz
Binary file not shown.
Binary file added dist/matrix-commander-2.38.1.tar.gz
Binary file not shown.
Binary file removed dist/matrix_commander-2.38.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/matrix_commander-2.38.1-py3-none-any.whl
Binary file not shown.
1,767 changes: 1,395 additions & 372 deletions matrix_commander/matrix_commander.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.38.0
version = 2.38.1
author = 8go
description = A simple command-line Matrix client
long_description = file: PyPi-Instructions.md, README.md
Expand Down
14 changes: 7 additions & 7 deletions tests/test-setget.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function test11() {

function test12() {
echo "=== Test 12: adding an alias to the default room ==="
matrix-commander --room-set-alias " spaces not allowed" r "mustStartWith#" r "" r $MC_OPTIONS
matrix-commander --room-set-alias " spaces not allowed" r "wrong#" r "" r $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "FAILURE. The program should have failed, but didn't."
Expand All @@ -241,7 +241,7 @@ function test12() {

function test13() {
echo "=== Test 13: adding an alias to the default room ==="
matrix-commander --room-set-alias "#Testing-room-A" $MC_OPTIONS
matrix-commander --room-set-alias "Testing-room-A" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "SUCCESS. Alias set."
Expand All @@ -253,7 +253,7 @@ function test13() {

function test14() {
echo "=== Test 14: adding an alias to the default room ==="
matrix-commander --room-set-alias "#Testing-room-B" $MC_OPTIONS
matrix-commander --room-set-alias "Testing-room-B" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "SUCCESS. Alias set."
Expand All @@ -265,7 +265,7 @@ function test14() {

function test15() {
echo "=== Test 15: resolving a room alias ==="
matrix-commander --room-resolve-alias "#doesntexist" "missing#" " spa ce " "#doesntexisteither" $MC_OPTIONS
matrix-commander --room-resolve-alias "doesntexist" "doesntexist2" "wrong#" " spa ce " "wrong:too" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "FAILURE. The program should have failed, but didn't."
Expand All @@ -277,7 +277,7 @@ function test15() {

function test16() {
echo "=== Test 16: resolving a room alias ==="
matrix-commander --room-resolve-alias "#Testing-room-A" "#Testing-room-B" $MC_OPTIONS
matrix-commander --room-resolve-alias "Testing-room-A" "Testing-room-B" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "SUCCESS. Aliases resolved."
Expand All @@ -289,7 +289,7 @@ function test16() {

function test17() {
echo "=== Test 17: deleting a room alias ==="
matrix-commander --room-delete-alias "#doesntexist" "missing#" " spa ce " "#doesntexisteither" $MC_OPTIONS
matrix-commander --room-delete-alias "doesntexist" "doesntexist2" "wrong#" " spa ce " "wrong:too" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "FAILURE. The program should have failed, but didn't."
Expand All @@ -301,7 +301,7 @@ function test17() {

function test18() {
echo "=== Test 18: deleting a room alias ==="
matrix-commander --room-delete-alias "#Testing-room-A" "#Testing-room-B" $MC_OPTIONS
matrix-commander --room-delete-alias "Testing-room-A" "Testing-room-B" $MC_OPTIONS
res="$?"
if [ "$res" == "0" ]; then
echo "SUCCESS. Alias deleted."
Expand Down

0 comments on commit 9a08ecb

Please sign in to comment.