From 55858ece854cc73a4b42c9f2c61124d6815b77a7 Mon Sep 17 00:00:00 2001 From: Cristian Marcos Martin Date: Thu, 12 Mar 2026 23:18:46 +0100 Subject: [PATCH 1/2] Make version number dynamic, add a flag to display it and change some help messages --- cloudisk/__init__.py | 3 +++ cloudisk/cli/parser.py | 33 ++++++++++++++++++++++++++++----- cloudisk/vars.py | 2 ++ pyproject.toml | 3 +++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cloudisk/__init__.py b/cloudisk/__init__.py index a2c33cc..6920b0a 100644 --- a/cloudisk/__init__.py +++ b/cloudisk/__init__.py @@ -1 +1,4 @@ from cloudisk.cli import main as main +from cloudisk.vars import VERSION + +__version__ = ".".join(str(x) for x in VERSION) diff --git a/cloudisk/cli/parser.py b/cloudisk/cli/parser.py index d39ef6f..72fb194 100644 --- a/cloudisk/cli/parser.py +++ b/cloudisk/cli/parser.py @@ -13,7 +13,7 @@ use_space, ) from cloudisk.http import server -from cloudisk.vars import CLOUDISK_ROOT +from cloudisk.vars import CLOUDISK_ROOT, VERSION app = typer.Typer( name="cloudisk", @@ -21,12 +21,35 @@ ) +def version_cb(value: bool): + if value: + version = ".".join(str(x) for x in VERSION) + typer.echo(f"cloudisk v{version}") + raise typer.Exit() + + +@app.callback() +def main( + version: Annotated[ + bool | None, + typer.Option( + "--version", + "-v", + help="Print the version number", + callback=version_cb, + is_eager=True, + ), + ] = None, +): + pass + + @app.command(help=f"Creates the basic scaffolding at '{CLOUDISK_ROOT}'") def init(): init_cloudisk_root() -@app.command(help=f"Creates a new space inside '{CLOUDISK_ROOT}'") +@app.command(help="Creates a new space") def create( name: Annotated[ Optional[str], @@ -61,7 +84,7 @@ def create( create_space(name, protect) -@app.command(help=f"Use a space inside '{CLOUDISK_ROOT}'") +@app.command(help="Change the used space") def use( name: Annotated[ str, @@ -76,7 +99,7 @@ def list(): list_spaces() -@app.command(help=f"Creates a symlink inside '{CLOUDISK_ROOT}'") +@app.command(help=f"Creates a symlink (soft) inside '{CLOUDISK_ROOT}'") def link( path: Annotated[ Path, @@ -99,7 +122,7 @@ def link( link_path(path, recursive) -@app.command(help=f"Removes a symlink inside '{CLOUDISK_ROOT}'") +@app.command(help=f"Removes a symlink (soft) inside '{CLOUDISK_ROOT}'") def unlink( path: Annotated[ Path, diff --git a/cloudisk/vars.py b/cloudisk/vars.py index cef1cf7..e6b06c5 100644 --- a/cloudisk/vars.py +++ b/cloudisk/vars.py @@ -1,5 +1,7 @@ from pathlib import Path +VERSION = (0, 2, 0) + CLOUDISK_ROOT = Path.home() / ".cloudisk" CLOUDISK_DB_FILE = ".cloudisk.db" diff --git a/pyproject.toml b/pyproject.toml index 17c30e9..bc77e07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,9 @@ build = [ "build>=1.4.0", ] +[tool.setuptools.dynamic] +version = {attr = "cloudisk.__version__"} + [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py"] From de23417bec7a122c728251a5b448ac4e0ed0a681 Mon Sep 17 00:00:00 2001 From: Cristian Marcos Martin Date: Thu, 12 Mar 2026 23:31:34 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 91d300b..7664104 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,34 @@ To install cloudisk, use `pip install cloudisk`. After installing, you can run `cloudisk -h` to get the full commands list and a their description. Use `cloudisk -h` to get help about their flags. -Use `cloudisk run` to start the web server at `127.0.0.1:8000`. +Cloudisk works with `spaces`, which are isolated server instances. +Run `cloudisk create` to make a new space. -## Environment variables +Then, use `cloudisk run` to start the web server at `127.0.0.1:8000`. -The following env vars are used by cloudisk: +If you want to use a different space, run `cloudisk use [NAME]`. -- `CLOUDISK_STATIC`: the path of the static files that will be served. +## Configuration + +As mentioned before, cloudisk manages different server instances with spaces. + +These spaces, the cloudisk database and the settings module are located in your +home directory: + +- Linux: `$HOME/.cloudisk` +- macOS: `$HOME/.cloudisk` +- Windows: `%USERPROFILE%/.cloudisk` + +The `.cloudisk` directory is created automatically, but you can also use +`cloudisk init` to generate it. + +Right now, all spaces share the same database and settings module. In the +future, each space will have it's own settings module. + +The settings module is just a Python file that contains some optional variables: +- `STATIC_PATH`: the path where the static files will be served from. +- `EMAIL_FROM`: the email of the account that sends the account verification email. +- `PASS_FROM`: the password of the account that sends the account verification email. + +You can also set them up as environment variables by adding `CLOUDISK_` prefix +to the variable name. Eg.: `CLOUDISK_EMAIL_FROM`