Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command> -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`
3 changes: 3 additions & 0 deletions cloudisk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from cloudisk.cli import main as main
from cloudisk.vars import VERSION

__version__ = ".".join(str(x) for x in VERSION)
33 changes: 28 additions & 5 deletions cloudisk/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,43 @@
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",
help="A decentralized content distribution system. Run your own cloud.",
)


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],
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions cloudisk/vars.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path

VERSION = (0, 2, 0)

CLOUDISK_ROOT = Path.home() / ".cloudisk"

CLOUDISK_DB_FILE = ".cloudisk.db"
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading