slashed 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slashed-0.1.0/.copier-answers.yml +21 -0
- slashed-0.1.0/.github/FUNDING.yml +3 -0
- slashed-0.1.0/.github/copilot-instructions.md +19 -0
- slashed-0.1.0/.github/dependabot.yml +9 -0
- slashed-0.1.0/.github/workflows/build.yml +88 -0
- slashed-0.1.0/.github/workflows/documentation.yml +57 -0
- slashed-0.1.0/.gitignore +32 -0
- slashed-0.1.0/.pre-commit-config.yaml +48 -0
- slashed-0.1.0/LICENSE +22 -0
- slashed-0.1.0/PKG-INFO +140 -0
- slashed-0.1.0/README.md +92 -0
- slashed-0.1.0/docs/.empty +0 -0
- slashed-0.1.0/duties.py +60 -0
- slashed-0.1.0/mkdocs.yml +92 -0
- slashed-0.1.0/overrides/_dummy.txt +1 -0
- slashed-0.1.0/pyproject.toml +244 -0
- slashed-0.1.0/src/slashed/__init__.py +52 -0
- slashed-0.1.0/src/slashed/base.py +194 -0
- slashed-0.1.0/src/slashed/builtin/__init__.py +9 -0
- slashed-0.1.0/src/slashed/builtin/help_cmd.py +101 -0
- slashed-0.1.0/src/slashed/completers.py +305 -0
- slashed-0.1.0/src/slashed/completion.py +160 -0
- slashed-0.1.0/src/slashed/exceptions.py +9 -0
- slashed-0.1.0/src/slashed/log.py +46 -0
- slashed-0.1.0/src/slashed/output.py +35 -0
- slashed-0.1.0/src/slashed/py.typed +0 -0
- slashed-0.1.0/src/slashed/store.py +142 -0
- slashed-0.1.0/src/slashed/utils.py +51 -0
- slashed-0.1.0/tests/__init__.py +3 -0
- slashed-0.1.0/tests/conftest.py +1 -0
- slashed-0.1.0/tests/test_slashed.py +174 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changes here will be overwritten by Copier
|
|
2
|
+
_commit: v1.8.1
|
|
3
|
+
_src_path: .\copier-phil65\
|
|
4
|
+
author_email: philipptemminghoff@googlemail.com
|
|
5
|
+
author_fullname: Philipp Temminghoff
|
|
6
|
+
author_username: phil65
|
|
7
|
+
copyright_date: '2024'
|
|
8
|
+
copyright_holder: Philipp Temminghoff
|
|
9
|
+
copyright_holder_email: philipptemminghoff@googlemail.com
|
|
10
|
+
libraries_use_pydantic: false
|
|
11
|
+
libraries_use_qt: false
|
|
12
|
+
project_description: Slash commands and autocompletions
|
|
13
|
+
project_name: Slashed
|
|
14
|
+
python_minimum_version: '3.12'
|
|
15
|
+
python_package_command_line_name: slashed
|
|
16
|
+
python_package_distribution_name: slashed
|
|
17
|
+
python_package_import_name: slashed
|
|
18
|
+
repository_name: slashed
|
|
19
|
+
repository_namespace: phil65
|
|
20
|
+
repository_provider: github.com
|
|
21
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Code style
|
|
2
|
+
|
|
3
|
+
You can assume Python 3.12.
|
|
4
|
+
Use newest language features if possible
|
|
5
|
+
Consider using pattern matching, walrus operators and other new syntax features.
|
|
6
|
+
Adhere to pep8.
|
|
7
|
+
|
|
8
|
+
## Tests
|
|
9
|
+
|
|
10
|
+
Tests are written using PyTest. Dont put tests into a class.
|
|
11
|
+
|
|
12
|
+
## DocStrings
|
|
13
|
+
|
|
14
|
+
DocStrings are written in google-style.
|
|
15
|
+
Dont add the types to the "Args" section.
|
|
16
|
+
Only add a Return section if a value is returned and the meaning of the returned value
|
|
17
|
+
is not obvious.
|
|
18
|
+
You can use markdown admonitions with python-markdown syntax if neccessary (!!! info, !!! note, !!! warning).
|
|
19
|
+
You can use markdown tables and markdown lists if neccessary.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ${{ matrix.os }}
|
|
8
|
+
continue-on-error: ${{ matrix.python_version == '3.14' }}
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
python_version: ["3.12", "3.13", "3.14"]
|
|
12
|
+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
13
|
+
steps:
|
|
14
|
+
- name: Check out repository
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Set up Python ${{ matrix.python_version }}
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python_version }}
|
|
21
|
+
allow-prereleases: true
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v4
|
|
25
|
+
with:
|
|
26
|
+
enable-cache: true
|
|
27
|
+
cache-dependency-glob: pyproject.toml
|
|
28
|
+
cache-suffix: py${{ matrix.python_version }}
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies (uv sync)
|
|
31
|
+
run: uv sync --all-extras --no-group docs
|
|
32
|
+
|
|
33
|
+
- name: Check for code issues (ruff check)
|
|
34
|
+
uses: astral-sh/ruff-action@v1
|
|
35
|
+
|
|
36
|
+
- name: Check code format (ruff format)
|
|
37
|
+
uses: astral-sh/ruff-action@v1
|
|
38
|
+
with:
|
|
39
|
+
args: "format --check"
|
|
40
|
+
|
|
41
|
+
- name: Static type checking (MyPy)
|
|
42
|
+
run: uv run --no-group docs mypy src/slashed/
|
|
43
|
+
|
|
44
|
+
- name: Run tests
|
|
45
|
+
run: uv run --no-group docs pytest --cov-report=xml --cov=src/slashed/ --cov-report=term-missing
|
|
46
|
+
|
|
47
|
+
- name: Upload test results to Codecov
|
|
48
|
+
uses: codecov/codecov-action@v5
|
|
49
|
+
with:
|
|
50
|
+
fail_ci_if_error: false
|
|
51
|
+
verbose: true
|
|
52
|
+
|
|
53
|
+
release:
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
needs: test
|
|
56
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
57
|
+
permissions:
|
|
58
|
+
# this permission is mandatory for trusted publishing
|
|
59
|
+
id-token: write
|
|
60
|
+
contents: write
|
|
61
|
+
steps:
|
|
62
|
+
- name: Check out repository
|
|
63
|
+
uses: actions/checkout@v4
|
|
64
|
+
|
|
65
|
+
- name: Set up Python
|
|
66
|
+
uses: actions/setup-python@v5
|
|
67
|
+
with:
|
|
68
|
+
python-version: "3.12"
|
|
69
|
+
|
|
70
|
+
- name: Install uv
|
|
71
|
+
uses: astral-sh/setup-uv@v4
|
|
72
|
+
with:
|
|
73
|
+
enable-cache: true
|
|
74
|
+
cache-dependency-glob: pyproject.toml
|
|
75
|
+
cache-suffix: py${{ matrix.python_version }}
|
|
76
|
+
|
|
77
|
+
- name: Build package
|
|
78
|
+
run: uv build
|
|
79
|
+
|
|
80
|
+
- name: Publish package distributions to PyPI
|
|
81
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
82
|
+
|
|
83
|
+
- name: Release package on GitHub
|
|
84
|
+
uses: ncipollo/release-action@v1
|
|
85
|
+
with:
|
|
86
|
+
body: ${{ github.event.head_commit.message }}
|
|
87
|
+
artifacts: dist/*.whl,dist/*.tar.gz
|
|
88
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Build documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
# Allow one concurrent deployment
|
|
15
|
+
concurrency:
|
|
16
|
+
group: "pages"
|
|
17
|
+
cancel-in-progress: true
|
|
18
|
+
|
|
19
|
+
# Default to bash
|
|
20
|
+
defaults:
|
|
21
|
+
run:
|
|
22
|
+
shell: bash
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
build:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
- name: Set up Python
|
|
33
|
+
uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- name: Install uv
|
|
37
|
+
uses: astral-sh/setup-uv@v4
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: |
|
|
40
|
+
uv sync --all-extras
|
|
41
|
+
- name: Build
|
|
42
|
+
run: uv run mknodes build
|
|
43
|
+
- name: Upload artifact
|
|
44
|
+
uses: actions/upload-pages-artifact@v3
|
|
45
|
+
with:
|
|
46
|
+
path: ./site
|
|
47
|
+
|
|
48
|
+
deploy:
|
|
49
|
+
environment:
|
|
50
|
+
name: github-pages
|
|
51
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
needs: build
|
|
54
|
+
steps:
|
|
55
|
+
- name: Deploy to GitHub Pages
|
|
56
|
+
id: deployment
|
|
57
|
+
uses: actions/deploy-pages@v4
|
slashed-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
# Distribution / packaging
|
|
5
|
+
*.sublime-workspace
|
|
6
|
+
# Unit test / coverage reports
|
|
7
|
+
.coverage
|
|
8
|
+
coverage.xml
|
|
9
|
+
.cache
|
|
10
|
+
.hatch
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
junit.xml
|
|
13
|
+
# Jupyter Notebook
|
|
14
|
+
.ipynb_checkpoints
|
|
15
|
+
# pyenv
|
|
16
|
+
.python-version
|
|
17
|
+
# dotenv
|
|
18
|
+
.env
|
|
19
|
+
# virtualenv
|
|
20
|
+
.venv
|
|
21
|
+
# mkdocs documentation
|
|
22
|
+
/site
|
|
23
|
+
# mypy
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
# .vscode
|
|
26
|
+
.vscode/
|
|
27
|
+
# OS files
|
|
28
|
+
.DS_Store
|
|
29
|
+
# uv
|
|
30
|
+
uv.lock
|
|
31
|
+
# DiskCache cache file
|
|
32
|
+
./model_cache
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3.12
|
|
3
|
+
default_stages: [pre-commit]
|
|
4
|
+
repos:
|
|
5
|
+
- repo: local
|
|
6
|
+
hooks:
|
|
7
|
+
- id: pytest-check
|
|
8
|
+
name: pytest-check
|
|
9
|
+
entry: uv run pytest
|
|
10
|
+
language: system
|
|
11
|
+
# stages: [push]
|
|
12
|
+
types: [python]
|
|
13
|
+
pass_filenames: false
|
|
14
|
+
always_run: true
|
|
15
|
+
|
|
16
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
17
|
+
# https://pre-commit.com/hooks.html
|
|
18
|
+
rev: v5.0.0
|
|
19
|
+
hooks:
|
|
20
|
+
- id: check-added-large-files
|
|
21
|
+
- id: check-case-conflict
|
|
22
|
+
- id: check-merge-conflict
|
|
23
|
+
- id: check-toml
|
|
24
|
+
- id: check-json
|
|
25
|
+
- id: check-xml
|
|
26
|
+
- id: check-yaml
|
|
27
|
+
args: [--allow-multiple-documents, --unsafe]
|
|
28
|
+
- id: debug-statements
|
|
29
|
+
- id: detect-private-key
|
|
30
|
+
|
|
31
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
32
|
+
rev: v1.13.0
|
|
33
|
+
hooks:
|
|
34
|
+
- id: mypy
|
|
35
|
+
additional_dependencies: [orjson]
|
|
36
|
+
|
|
37
|
+
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
38
|
+
rev: v0.8.4
|
|
39
|
+
hooks:
|
|
40
|
+
- id: ruff
|
|
41
|
+
- id: ruff-format
|
|
42
|
+
|
|
43
|
+
- repo: https://github.com/commitizen-tools/commitizen
|
|
44
|
+
rev: v4.1.0
|
|
45
|
+
hooks:
|
|
46
|
+
- id: commitizen
|
|
47
|
+
stages: [commit-msg]
|
|
48
|
+
additional_dependencies: [typing-extensions]
|
slashed-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Philipp Temminghoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
slashed-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: slashed
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Slash commands and autocompletions
|
|
5
|
+
Project-URL: Documentation, https://phil65.github.io/slashed/
|
|
6
|
+
Project-URL: Source, https://github.com/phil65/slashed
|
|
7
|
+
Project-URL: Issues, https://github.com/phil65/slashed/issues
|
|
8
|
+
Project-URL: Discussions, https://github.com/phil65/slashed/discussions
|
|
9
|
+
Project-URL: Code coverage, https://app.codecov.io/gh/phil65/slashed
|
|
10
|
+
Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2024, Philipp Temminghoff
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
42
|
+
Classifier: Topic :: Documentation
|
|
43
|
+
Classifier: Topic :: Software Development
|
|
44
|
+
Classifier: Topic :: Utilities
|
|
45
|
+
Classifier: Typing :: Typed
|
|
46
|
+
Requires-Python: >=3.12
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# Slashed
|
|
50
|
+
|
|
51
|
+
[](https://pypi.org/project/slashed/)
|
|
52
|
+
[](https://pypi.org/project/slashed/)
|
|
53
|
+
[](https://pypi.org/project/slashed/)
|
|
54
|
+
[](https://pypi.org/project/slashed/)
|
|
55
|
+
[](https://pypi.org/project/slashed/)
|
|
56
|
+
[](https://pypi.org/project/slashed/)
|
|
57
|
+
[](https://pypi.org/project/slashed/)
|
|
58
|
+
[](https://pypi.org/project/slashed/)
|
|
59
|
+
[](https://pypi.org/project/slashed/)
|
|
60
|
+
[](https://github.com/phil65/slashed/releases)
|
|
61
|
+
[](https://github.com/phil65/slashed/graphs/contributors)
|
|
62
|
+
[](https://github.com/phil65/slashed/discussions)
|
|
63
|
+
[](https://github.com/phil65/slashed/forks)
|
|
64
|
+
[](https://github.com/phil65/slashed/issues)
|
|
65
|
+
[](https://github.com/phil65/slashed/pulls)
|
|
66
|
+
[](https://github.com/phil65/slashed/watchers)
|
|
67
|
+
[](https://github.com/phil65/slashed/stars)
|
|
68
|
+
[](https://github.com/phil65/slashed)
|
|
69
|
+
[](https://github.com/phil65/slashed/commits)
|
|
70
|
+
[](https://github.com/phil65/slashed/releases)
|
|
71
|
+
[](https://github.com/phil65/slashed)
|
|
72
|
+
[](https://github.com/phil65/slashed)
|
|
73
|
+
[](https://github.com/phil65/slashed)
|
|
74
|
+
[](https://github.com/phil65/slashed)
|
|
75
|
+
[](https://codecov.io/gh/phil65/slashed/)
|
|
76
|
+
[](https://github.com/psf/black)
|
|
77
|
+
[](https://pyup.io/repos/github/phil65/slashed/)
|
|
78
|
+
|
|
79
|
+
[Read the documentation!](https://phil65.github.io/slashed/)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
A simple Python library for implementing slash commands with autocompletion support.
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- Simple command registration system
|
|
87
|
+
- Rich autocompletion support
|
|
88
|
+
- Built-in file path and environment variable completion
|
|
89
|
+
- Extensible completion provider system
|
|
90
|
+
- Type-safe with full type hints
|
|
91
|
+
- Modern Python features (3.12+)
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install slashed
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Quick Example
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from slashed import Command, CommandStore, CommandContext
|
|
103
|
+
from slashed.output import DefaultOutputWriter
|
|
104
|
+
|
|
105
|
+
# Create a command store
|
|
106
|
+
store = CommandStore()
|
|
107
|
+
|
|
108
|
+
# Define a simple command
|
|
109
|
+
async def hello(ctx: CommandContext, args: list[str], kwargs: dict[str, str]) -> None:
|
|
110
|
+
name = args[0] if args else "World"
|
|
111
|
+
await ctx.output.print(f"Hello, {name}!")
|
|
112
|
+
|
|
113
|
+
hello_cmd = Command(
|
|
114
|
+
name="hello",
|
|
115
|
+
description="Say hello",
|
|
116
|
+
execute_func=hello,
|
|
117
|
+
usage="[name]"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Register the command
|
|
121
|
+
store.register_command(hello_cmd)
|
|
122
|
+
|
|
123
|
+
# Create output writer
|
|
124
|
+
output = DefaultOutputWriter()
|
|
125
|
+
|
|
126
|
+
# Execute a command
|
|
127
|
+
await store.execute_command("hello Phil", CommandContext(output=output, data=None))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Documentation
|
|
131
|
+
|
|
132
|
+
For full documentation, visit [slashed.readthedocs.io](https://phil65.github.io/slashed).
|
|
133
|
+
|
|
134
|
+
## Contributing
|
|
135
|
+
|
|
136
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
slashed-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Slashed
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/slashed/)
|
|
4
|
+
[](https://pypi.org/project/slashed/)
|
|
5
|
+
[](https://pypi.org/project/slashed/)
|
|
6
|
+
[](https://pypi.org/project/slashed/)
|
|
7
|
+
[](https://pypi.org/project/slashed/)
|
|
8
|
+
[](https://pypi.org/project/slashed/)
|
|
9
|
+
[](https://pypi.org/project/slashed/)
|
|
10
|
+
[](https://pypi.org/project/slashed/)
|
|
11
|
+
[](https://pypi.org/project/slashed/)
|
|
12
|
+
[](https://github.com/phil65/slashed/releases)
|
|
13
|
+
[](https://github.com/phil65/slashed/graphs/contributors)
|
|
14
|
+
[](https://github.com/phil65/slashed/discussions)
|
|
15
|
+
[](https://github.com/phil65/slashed/forks)
|
|
16
|
+
[](https://github.com/phil65/slashed/issues)
|
|
17
|
+
[](https://github.com/phil65/slashed/pulls)
|
|
18
|
+
[](https://github.com/phil65/slashed/watchers)
|
|
19
|
+
[](https://github.com/phil65/slashed/stars)
|
|
20
|
+
[](https://github.com/phil65/slashed)
|
|
21
|
+
[](https://github.com/phil65/slashed/commits)
|
|
22
|
+
[](https://github.com/phil65/slashed/releases)
|
|
23
|
+
[](https://github.com/phil65/slashed)
|
|
24
|
+
[](https://github.com/phil65/slashed)
|
|
25
|
+
[](https://github.com/phil65/slashed)
|
|
26
|
+
[](https://github.com/phil65/slashed)
|
|
27
|
+
[](https://codecov.io/gh/phil65/slashed/)
|
|
28
|
+
[](https://github.com/psf/black)
|
|
29
|
+
[](https://pyup.io/repos/github/phil65/slashed/)
|
|
30
|
+
|
|
31
|
+
[Read the documentation!](https://phil65.github.io/slashed/)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
A simple Python library for implementing slash commands with autocompletion support.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- Simple command registration system
|
|
39
|
+
- Rich autocompletion support
|
|
40
|
+
- Built-in file path and environment variable completion
|
|
41
|
+
- Extensible completion provider system
|
|
42
|
+
- Type-safe with full type hints
|
|
43
|
+
- Modern Python features (3.12+)
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install slashed
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Example
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from slashed import Command, CommandStore, CommandContext
|
|
55
|
+
from slashed.output import DefaultOutputWriter
|
|
56
|
+
|
|
57
|
+
# Create a command store
|
|
58
|
+
store = CommandStore()
|
|
59
|
+
|
|
60
|
+
# Define a simple command
|
|
61
|
+
async def hello(ctx: CommandContext, args: list[str], kwargs: dict[str, str]) -> None:
|
|
62
|
+
name = args[0] if args else "World"
|
|
63
|
+
await ctx.output.print(f"Hello, {name}!")
|
|
64
|
+
|
|
65
|
+
hello_cmd = Command(
|
|
66
|
+
name="hello",
|
|
67
|
+
description="Say hello",
|
|
68
|
+
execute_func=hello,
|
|
69
|
+
usage="[name]"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Register the command
|
|
73
|
+
store.register_command(hello_cmd)
|
|
74
|
+
|
|
75
|
+
# Create output writer
|
|
76
|
+
output = DefaultOutputWriter()
|
|
77
|
+
|
|
78
|
+
# Execute a command
|
|
79
|
+
await store.execute_command("hello Phil", CommandContext(output=output, data=None))
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
For full documentation, visit [slashed.readthedocs.io](https://phil65.github.io/slashed).
|
|
85
|
+
|
|
86
|
+
## Contributing
|
|
87
|
+
|
|
88
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
File without changes
|
slashed-0.1.0/duties.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from duty import duty
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@duty(capture=False)
|
|
7
|
+
def build(ctx, *args: str):
|
|
8
|
+
"""Build a MkNodes page."""
|
|
9
|
+
args_str = " " + " ".join(args) if args else ""
|
|
10
|
+
ctx.run(f"uv run mknodes build{args_str}")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@duty(capture=False)
|
|
14
|
+
def serve(ctx, *args: str):
|
|
15
|
+
"""Serve a MkNodes page."""
|
|
16
|
+
args_str = " " + " ".join(args) if args else ""
|
|
17
|
+
ctx.run(f"uv run mknodes serve{args_str}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@duty(capture=False)
|
|
21
|
+
def test(ctx, *args: str):
|
|
22
|
+
"""Serve a MkNodes page."""
|
|
23
|
+
args_str = " " + " ".join(args) if args else ""
|
|
24
|
+
ctx.run(f"uv run pytest{args_str}")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@duty(capture=False)
|
|
28
|
+
def clean(ctx):
|
|
29
|
+
"""Clean all files from the Git directory except checked-in files."""
|
|
30
|
+
ctx.run("git clean -dfX")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@duty(capture=False)
|
|
34
|
+
def update(ctx):
|
|
35
|
+
"""Update all environment packages using pip directly."""
|
|
36
|
+
ctx.run("uv lock --upgrade")
|
|
37
|
+
ctx.run("uv sync --all-extras")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@duty(capture=False)
|
|
41
|
+
def lint(ctx):
|
|
42
|
+
"""Lint the code and fix issues if possible."""
|
|
43
|
+
ctx.run("uv run ruff check --fix --unsafe-fixes .")
|
|
44
|
+
ctx.run("uv run ruff format .")
|
|
45
|
+
ctx.run("uv run mypy src/slashed/")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@duty(capture=False)
|
|
49
|
+
def lint_check(ctx):
|
|
50
|
+
"""Lint the code."""
|
|
51
|
+
ctx.run("uv run ruff check .")
|
|
52
|
+
ctx.run("uv run ruff format --check .")
|
|
53
|
+
ctx.run("uv run mypy src/slashed/")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@duty(capture=False)
|
|
57
|
+
def version(ctx, *args: str):
|
|
58
|
+
"""Bump package version."""
|
|
59
|
+
args_str = " " + " ".join(args) if args else ""
|
|
60
|
+
ctx.run(f"hatch version{args_str}")
|