add readme, fix poetry configuration, tidy up
This commit is contained in:
parent
2c09cfe11e
commit
e21703965f
58
README.md
Normal file
58
README.md
Normal file
@ -0,0 +1,58 @@
|
||||
# lunduke-cli
|
||||
|
||||
A simple python api client for discourse, designed explicitly
|
||||
for the lunduke discourse message board, but it could be used
|
||||
with any discourse message board.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Python 3.12 (or better)
|
||||
* Poetry 2.0 (or better)
|
||||
|
||||
Poetry's pyproject.toml handles all other requirements.
|
||||
|
||||
## Initialization
|
||||
|
||||
```shell
|
||||
$ poetry install
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
See the "examples" directory. However, there are some
|
||||
additional notes you will need, in order to make it work.
|
||||
|
||||
First, a `keys` directory at the root of the project, where
|
||||
you will store a user api key you have already generated. A
|
||||
well formed api key should look something like this:
|
||||
|
||||
```
|
||||
X4ktxE5tsvC+RcvjF9Pa1N//PWTgjAF1xx5UcuaHFVKu84A14n6stDheUxxx
|
||||
xxx8xxxUbpVN3xOtDxxIg5sU4ZjAZ+LRyKxU9+ikQMqno4Spqb9SOrclxxxx
|
||||
5Lo/6xkBB/xM9/Rxxx3I0ZAcvurYeIHkVQmSigmaPMJBjx/MKLMGdlVOq+is
|
||||
mxu7qTQcl85E5k0MC86LNr5Ds4xUQXgIGVGVICxxxUMr2VxxxD9tglgG+9sL
|
||||
VYFehH4HxxPxx67XRfrq8WxZjYRMHcWaGO4O03lQZwPEpIz7aL6D6wPNdCaq
|
||||
nH9ivM/3MdEUOQZQuh8R+XJ9Ik7RlTLNVxx8bxTJ2X==
|
||||
```
|
||||
|
||||
Second, you will need a file called `config.toml` in the root
|
||||
of the project. That file should look like this:
|
||||
|
||||
```ini
|
||||
[user]
|
||||
username = "joe-doakes"
|
||||
|
||||
[api]
|
||||
key_file = "cli_key.txt"
|
||||
host = "forum.wherever.com"
|
||||
```
|
||||
|
||||
Then, you can run the test scripts either with or without
|
||||
poetry support:
|
||||
|
||||
```shell
|
||||
$ poetry run python examples/check-key.py # for example
|
||||
|
||||
$ python examples/example.py # for example
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
|
||||
from io import StringIO
|
||||
import toml
|
||||
|
||||
|
||||
@ -14,13 +14,18 @@ def create_sample_config(config_path="config.toml"):
|
||||
"username": "joe_doakes"
|
||||
},
|
||||
"api": {
|
||||
"key_file": "../keys/cli_key.txt",
|
||||
"key_file": "cli_key.txt",
|
||||
"host": "discourse.forum.com"
|
||||
}
|
||||
}
|
||||
|
||||
buffer = StringIO()
|
||||
toml.dump(config_data, buffer)
|
||||
with open(config_path, "w") as config_file:
|
||||
toml.dump(config_data, config_file)
|
||||
config_file.write(buffer.getvalue())
|
||||
|
||||
# with open(config_path, "w") as config_file:
|
||||
# toml.dump(config_data, config_file) # type: ignore
|
||||
|
||||
print(f"Created sample configuration file: {config_path}")
|
||||
|
||||
|
@ -6,7 +6,6 @@ from lunduke.client import DiscourseClient
|
||||
|
||||
def main():
|
||||
config_data = Config()
|
||||
print(config_data)
|
||||
|
||||
# Set up configuration
|
||||
config = DiscourseConfig(
|
||||
|
@ -1,17 +1,18 @@
|
||||
[project]
|
||||
[tool.poetry]
|
||||
name = "lunduke-cli"
|
||||
version = "0.1.0"
|
||||
description = "An API client for the Lunduke Discourse server"
|
||||
authors = [
|
||||
{name = "Greg Gauthier",email = "gmgauthier@protonmail.com"}
|
||||
]
|
||||
authors = ["Greg Gauthier <gmgauthier@protonmail.com>"]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"requests (>=2.32.3,<3.0.0)",
|
||||
"toml (>=0.10.2, <1.0.0)"
|
||||
packages = [
|
||||
{include = "config"},
|
||||
{include = "lunduke"}
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.12"
|
||||
requests = ">=2.32.3,<3.0.0"
|
||||
toml = ">=0.10.2, <1.0.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
|
Loading…
Reference in New Issue
Block a user