spaceworld


Namespaceworld JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummarySpaceworld is a new generation Cli framework for convenient development of your teams written in Python 3.12+ with support for asynchronous commands
upload_time2025-09-08 05:26:59
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
keywords python shell cli performance terminal async python3 typehints spaceworld
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SpaceWorld
[![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI version](https://img.shields.io/pypi/v/spaceworld?color=%2334D058&label=pypi%20package)](https://pypi.org/project/spaceworld)
[![PyPI Downloads](https://static.pepy.tech/badge/spaceworld)](https://pepy.tech/projects/spaceworld)

**Spaceworld is a new generation Cli framework for convenient development of your
teams written in Python 3.12+ with support for asynchronous commands**

Source Code: https://github.com/Binobinos/SpaceWorld
documentation: https://binobinos.github.io/Spaceworld

The key features are:

- Highest speed: For high-load applications
  - Huge flexibility: The ability to customize handlers, commands, and modules
  - Code simplicity: With all the advantages, your code remains as simple as possible
  - Support for *args, **kwargs
  - Extended type annotations: Use new annotations like Annotated, Literal, Union, and others
  - Support for Validators and transformers in annotations

# Install Spaceworld

The first step is to install SpaceWorld.

First, make sure you create your virtual environment, activate it, and then install it, for example with:

```shell
pip install spaceworld
```

# Example

The simplest example

```python
import spaceworld


def main():
    print("Hello World")


if __name__ == '__main__':
    spaceworld.run(main)
```

Copy that to a file main.py.

Test it:

```
$ python main.py main

Hello World

$ python main.py main --help

Usage: main [ARGS] [OPTIONS]  
None documentation

Options:
  --help - Displays the help on the command

```

# One Cli argument

This output for the function looks very simple.
Let's create a new function. hello, which displays a welcome message to the user

```python
import spaceworld


def hello(name: str):
    print(f"Hello {name}")


if __name__ == '__main__':
    spaceworld.run(hello)
```

Now let's run this script and see what happens.

```shell
$ python spaceworld_.py hello

ERROR: Missing required argument: 'name'
```

We see an error due to the absence of the name argument. Let's welcome bino

```shell
$ python spaceworld_.py hello bino

Hello bino
```
# Async command

Creating an asynchronous command

```python
import asyncio

import spaceworld


async def sleep(second: int):
    await asyncio.sleep(second)
    print(f"Hello in {second} second")


if __name__ == '__main__':
    spaceworld.run(sleep)

```

Copy that to a file main.py.

Test it:
```shell
$ python .\main.py sleep 1

# After 1 second
Hello in 1 second

$ python .\main.py sleep

# After 1 second
Hello in 1 second

$ python .\main.py sleep 5

# After 5 second
Hello in 5 second
```

# The validation Command

Creating a validation Command

```python

from typing import Annotated

import spaceworld


def check(
        age: Annotated[
            int,
            lambda x: x if x >= 18 else
            ValueError("The user must be over 18 years old")]):
    print(f"Hello {age} year old")


if __name__ == '__main__':
    spaceworld.run(check)

```

Copy that to a file main.py.

Test it:
```shell
$ python .\main.py check 1

ERROR:Invalid argument for 'age':
Error in the Annotated validation for `1`: Arg: 1, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>      

$ python .\main.py check 15

ERROR:Invalid argument for 'age': 
Error in the Annotated validation for `15`: Arg: 15, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>

$ python .\main.py check 18

Hello 18 year old

$ python .\main.py check -1

ERROR:Invalid argument for 'age': 
Error in the Annotated validation for `-1`: Arg: -1, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>
```

---

# New features in v1.0.0

## The decorators' style

## Modules as a command

## Checking the number of positional and named arguments

Great!
As we can see, we entered the hello command with the bino argument and the script displayed greeting messages to him.

But what if we want to make a conclusion in big letters? Then let's add a flag.

## License

This project is licensed under the terms of the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "spaceworld",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "python, shell, cli, performance, terminal, async, python3, typehints, spaceworld",
    "author": null,
    "author_email": "binobinos <binobinos.dev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e0/3e/c89abedf3339ef98e028fa6aee2dcd2eb4ff52a2817d36e0632b7189815e/spaceworld-2.0.0.tar.gz",
    "platform": null,
    "description": "# SpaceWorld\r\n[![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/)\r\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![PyPI version](https://img.shields.io/pypi/v/spaceworld?color=%2334D058&label=pypi%20package)](https://pypi.org/project/spaceworld)\r\n[![PyPI Downloads](https://static.pepy.tech/badge/spaceworld)](https://pepy.tech/projects/spaceworld)\r\n\r\n**Spaceworld is a new generation Cli framework for convenient development of your\r\nteams written in Python 3.12+ with support for asynchronous commands**\r\n\r\nSource Code: https://github.com/Binobinos/SpaceWorld\r\ndocumentation: https://binobinos.github.io/Spaceworld\r\n\r\nThe key features are:\r\n\r\n- Highest speed: For high-load applications\r\n  - Huge flexibility: The ability to customize handlers, commands, and modules\r\n  - Code simplicity: With all the advantages, your code remains as simple as possible\r\n  - Support for *args, **kwargs\r\n  - Extended type annotations: Use new annotations like Annotated, Literal, Union, and others\r\n  - Support for Validators and transformers in annotations\r\n\r\n# Install Spaceworld\r\n\r\nThe first step is to install SpaceWorld.\r\n\r\nFirst, make sure you create your virtual environment, activate it, and then install it, for example with:\r\n\r\n```shell\r\npip install spaceworld\r\n```\r\n\r\n# Example\r\n\r\nThe simplest example\r\n\r\n```python\r\nimport spaceworld\r\n\r\n\r\ndef main():\r\n    print(\"Hello World\")\r\n\r\n\r\nif __name__ == '__main__':\r\n    spaceworld.run(main)\r\n```\r\n\r\nCopy that to a file main.py.\r\n\r\nTest it:\r\n\r\n```\r\n$ python main.py main\r\n\r\nHello World\r\n\r\n$ python main.py main --help\r\n\r\nUsage: main [ARGS] [OPTIONS]  \r\nNone documentation\r\n\r\nOptions:\r\n  --help - Displays the help on the command\r\n\r\n```\r\n\r\n# One Cli argument\r\n\r\nThis output for the function looks very simple.\r\nLet's create a new function. hello, which displays a welcome message to the user\r\n\r\n```python\r\nimport spaceworld\r\n\r\n\r\ndef hello(name: str):\r\n    print(f\"Hello {name}\")\r\n\r\n\r\nif __name__ == '__main__':\r\n    spaceworld.run(hello)\r\n```\r\n\r\nNow let's run this script and see what happens.\r\n\r\n```shell\r\n$ python spaceworld_.py hello\r\n\r\nERROR: Missing required argument: 'name'\r\n```\r\n\r\nWe see an error due to the absence of the name argument. Let's welcome bino\r\n\r\n```shell\r\n$ python spaceworld_.py hello bino\r\n\r\nHello bino\r\n```\r\n# Async command\r\n\r\nCreating an asynchronous command\r\n\r\n```python\r\nimport asyncio\r\n\r\nimport spaceworld\r\n\r\n\r\nasync def sleep(second: int):\r\n    await asyncio.sleep(second)\r\n    print(f\"Hello in {second} second\")\r\n\r\n\r\nif __name__ == '__main__':\r\n    spaceworld.run(sleep)\r\n\r\n```\r\n\r\nCopy that to a file main.py.\r\n\r\nTest it:\r\n```shell\r\n$ python .\\main.py sleep 1\r\n\r\n# After 1 second\r\nHello in 1 second\r\n\r\n$ python .\\main.py sleep\r\n\r\n# After 1 second\r\nHello in 1 second\r\n\r\n$ python .\\main.py sleep 5\r\n\r\n# After 5 second\r\nHello in 5 second\r\n```\r\n\r\n# The validation Command\r\n\r\nCreating a validation Command\r\n\r\n```python\r\n\r\nfrom typing import Annotated\r\n\r\nimport spaceworld\r\n\r\n\r\ndef check(\r\n        age: Annotated[\r\n            int,\r\n            lambda x: x if x >= 18 else\r\n            ValueError(\"The user must be over 18 years old\")]):\r\n    print(f\"Hello {age} year old\")\r\n\r\n\r\nif __name__ == '__main__':\r\n    spaceworld.run(check)\r\n\r\n```\r\n\r\nCopy that to a file main.py.\r\n\r\nTest it:\r\n```shell\r\n$ python .\\main.py check 1\r\n\r\nERROR:Invalid argument for 'age':\r\nError in the Annotated validation for `1`: Arg: 1, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>      \r\n\r\n$ python .\\main.py check 15\r\n\r\nERROR:Invalid argument for 'age': \r\nError in the Annotated validation for `15`: Arg: 15, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>\r\n\r\n$ python .\\main.py check 18\r\n\r\nHello 18 year old\r\n\r\n$ python .\\main.py check -1\r\n\r\nERROR:Invalid argument for 'age': \r\nError in the Annotated validation for `-1`: Arg: -1, Error: The user must be over 18 years old, <class 'spaceworld.exceptions.annotations_error.AnnotationsError'>\r\n```\r\n\r\n---\r\n\r\n# New features in v1.0.0\r\n\r\n## The decorators' style\r\n\r\n## Modules as a command\r\n\r\n## Checking the number of positional and named arguments\r\n\r\nGreat!\r\nAs we can see, we entered the hello command with the bino argument and the script displayed greeting messages to him.\r\n\r\nBut what if we want to make a conclusion in big letters? Then let's add a flag.\r\n\r\n## License\r\n\r\nThis project is licensed under the terms of the MIT license.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Spaceworld is a new generation Cli framework for convenient development of your teams written in Python 3.12+ with support for asynchronous commands",
    "version": "2.0.0",
    "project_urls": {
        "Bug": "https://github.com/Binobinos/SpaceWorld/issues",
        "Changelog": "https://github.com/Binobinos/Spaceworld/blob/main/CHANGELOG.md",
        "Documentation": "https://spaceworld.binobinos.com/",
        "Homepage": "https://github.com/Binobinos/SpaceWorld",
        "Releases": "https://github.com/Binobinos/SpaceWorld/releases"
    },
    "split_keywords": [
        "python",
        " shell",
        " cli",
        " performance",
        " terminal",
        " async",
        " python3",
        " typehints",
        " spaceworld"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e4a72e6d8f707f0f4789dee23998158c98979ff1cdc7c351f8372587b869bea3",
                "md5": "dc14305efd6cfec5560d0e8c04087cc5",
                "sha256": "6aaa7082892ce79251f16f0e3b3f9a88a85e19959975203b171d75677852424f"
            },
            "downloads": -1,
            "filename": "spaceworld-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dc14305efd6cfec5560d0e8c04087cc5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 30365,
            "upload_time": "2025-09-08T05:26:57",
            "upload_time_iso_8601": "2025-09-08T05:26:57.464477Z",
            "url": "https://files.pythonhosted.org/packages/e4/a7/2e6d8f707f0f4789dee23998158c98979ff1cdc7c351f8372587b869bea3/spaceworld-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e03ec89abedf3339ef98e028fa6aee2dcd2eb4ff52a2817d36e0632b7189815e",
                "md5": "08147f23b68c386dd2ba1cd7c4ad421b",
                "sha256": "e317fcdb5019d02e06b130337ed302ac5b61384e8262272a2569a9e6a1cb1377"
            },
            "downloads": -1,
            "filename": "spaceworld-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "08147f23b68c386dd2ba1cd7c4ad421b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 29569,
            "upload_time": "2025-09-08T05:26:59",
            "upload_time_iso_8601": "2025-09-08T05:26:59.036106Z",
            "url": "https://files.pythonhosted.org/packages/e0/3e/c89abedf3339ef98e028fa6aee2dcd2eb4ff52a2817d36e0632b7189815e/spaceworld-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 05:26:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Binobinos",
    "github_project": "SpaceWorld",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "spaceworld"
}
        
Elapsed time: 1.16729s