Skip to content

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
silvncr committed Oct 22, 2024
0 parents commit 9bc81b9
Show file tree
Hide file tree
Showing 13 changed files with 802 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
27 changes: 27 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: publish
on:
release:
types: [published]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build pytest-runner setuptools wheel
pip install -r requirements.txt
- name: Build package
run: python -m build -n
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
155 changes: 155 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Visual Studio Code
.vscode/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.10
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023-2024 silvncr

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!-- omit from toc -->
# jarguments

simplifying args jargon

![version](https://img.shields.io/pypi/v/jarguments)
![status](https://img.shields.io/github/actions/workflow/status/silvncr/jarguments/python-publish.yml)
![downloads](https://img.shields.io/pypi/dm/jarguments)

![license](https://img.shields.io/github/license/silvncr/jarguments)
![format](https://img.shields.io/pypi/format/jarguments)
![pyversions](https://img.shields.io/pypi/pyversions/jarguments)

![repo-size](https://img.shields.io/github/repo-size/silvncr/jarguments)
![code-size](https://img.shields.io/github/languages/code-size/silvncr/jarguments)

## Summary

Provides a straightforward way to create command line arguments.

- :snake: Supports Python 3.8 and above. Tested on Windows 10.
- :construction: This project is still in development. Contributions are welcome!
- :star: Show your support by leaving a star!

## Contents

- [Summary](#summary)
- [Contents](#contents)
- [Installation](#installation)
- [Usage](#usage)

## Installation

```sh
python -m pip install --upgrade jarguments
```

> [!WARNING]
> All versions before `0.3.0` have been unpublished [due to a major oversight](https://silvncr.github.io/random/2024/10/21/regarding-deleted-commit-histories.html). Please update to the latest version.
## Usage

There are three steps to using the jarguments library:

1. Import the jarguments library.

```py
from jarguments import create, parse
```

2. Provide your arguments with jarguments' classes.

```py
# argument parser
args = parse.JParser(

# boolean argument
create.JBool('show-text', helpstring='determines whether "text" is shown'),

# integer argument
create.JInt('number', default=1),

# string argument
create.JStr('text'),
)
```

3. Use the outputs; they're parsed automatically!

```py
if args.show_text:
for _ in range(args.number):
print(args.text)
```

Now it works just like any other command line application.

```sh
$ python example.py --show-text --text "hello" "world"
["hello", "world"]
```

- Arguments without a default value are required. If you don't provide them, the script will raise an error:

```sh
$ python example.py --show-text
error: the following arguments are required: --text
```

- The `--help`/`-h` flag displays help messages:

```sh
$ python example.py -h
usage: example.py [-h] [--show-text [SHOW_TEXT]] [--number NUMBER] --text [TEXT ...]
options:
-h, --help show this help message and exit
--show-text [SHOW_TEXT]
determines whether "text" is shown
--number NUMBER
--text [TEXT ...]
```
14 changes: 14 additions & 0 deletions jarguments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'Provides a straightforward way to create command line arguments.'

try:
from . import create, handle, parse
except ImportError:
import create
import handle
import parse


__author__ = 'silvncr'
__license__ = 'MIT'
__module__ = 'jarguments'
__version__ = '0.3.0'
Loading

0 comments on commit 9bc81b9

Please sign in to comment.