Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkirsche/os-exitcodes
Cross OS exit codes
https://github.com/kkirsche/os-exitcodes
Last synced: about 1 month ago
JSON representation
Cross OS exit codes
- Host: GitHub
- URL: https://github.com/kkirsche/os-exitcodes
- Owner: kkirsche
- License: mit
- Created: 2022-08-18T15:25:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-18T15:39:16.000Z (over 2 years ago)
- Last Synced: 2024-10-14T09:25:53.490Z (2 months ago)
- Language: Python
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Exit Codes
This package is a cross-operating-system compatible version of the `os` library's EX\_\* constants.
If these constants are available, they will be re-exported directly from `os`, otherwise the integer version will be provided from this library.
This library also provides an enum version of the exit codes, if that is of value.
Apologies for the weird PyPi name, they're a bit overly restrictive and don't point to what specifically is the conflicting package.
## Installation
```shell
python -m pip install -U os-exitcodes
```## Usage
### Constants
```python
from os_exitcodes import (
EX_OK,
EX_USAGE,
)
from random import choicedef is_valid_usage() -> bool:
# check if the user is using this properly
# for a working example, this is random
return choice([True, False])def main() -> None:
invalid_usage = random
if not is_valid_usage():
raise SystemExit(EX_USAGE)
raise SystemExit(EX_OK)if __name__ == "__main__":
main()
```### Enumeration
```python
from os_exitcodes import ExitCode
from random import choicedef is_valid_usage() -> bool:
# check if the user is using this properly
# for a working example, this is random
return choice([True, False])def main() -> None:
invalid_usage = random
if not is_valid_usage():
raise SystemExit(ExitCode.EX_USAGE)
raise SystemExit(ExitCode.EX_OK)if __name__ == "__main__":
main()
```