Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

4 changed files with 16 additions and 31 deletions

View File

@ -14,27 +14,13 @@ nxexpo it's a simple tool to define environment variables on-the-fly and persist
- [MyPy](https://www.mypy-lang.org/) - [MyPy](https://www.mypy-lang.org/)
## Installation ## Installation
### Installation trough PyPI
To install the latest stable version follow the commands:
```Bash
$ pip install nvexpo --user
```
You can also use [pipx](https://pypa.github.io/pipx/) to install it:
```Bash
$ pipx install nvexpo
```
### From the source
To install from the source follow the commands: To install from the source follow the commands:
```Bash ```Bash
$ poetry build $ poetry build
$ pip install dist/nvexpo*.whl $ pip install dist/nvexpo*.whl
``` ```
## Preparation And add the follow line to your `.bashrc` file:
Add the following line to your `.bashrc` file:
```Bash ```Bash
eval "$(nvexpo init bash)" eval "$(nvexpo init bash)"
``` ```
@ -64,8 +50,8 @@ $ works!!
``` ```
## Why? ## Why?
The main motivation for creating this tool was that in my work I like to have the Git branch I'm working on in `$branch`, but it's annoying to have to create it every time I restart or close the terminal I was working on. The main motivation for creating this tool was that in my work I like to have the Git branch I'm working on in `$branch`, but it's annoying to have to create it every time I restart or close the terminal I was working on.
I could add it to `.bashrc` directly, but I would have to do it every time I have to work on a new branch and it wasn't comfortable. I could add it to `.bashrc` directly, but I would have to do it every time I have to work on a new branch and it wasn't comfortable.
So now instead of having to type: So now instead of having to type:
```Bash ```Bash
branch="super_useful_change" branch="super_useful_change"

View File

@ -3,8 +3,8 @@
import re import re
import sys import sys
from nvexpo import consts as CONSTS
from nvexpo import nvexpo from nvexpo import nvexpo
from nvexpo import consts as CONSTS
def main() -> int: def main() -> int:
@ -17,6 +17,10 @@ def main() -> int:
nvexpo.unset_env(args[2:]) nvexpo.unset_env(args[2:])
return 0 return 0
if args[1] in ["--load"]:
nvexpo._load()
return 0
if args[1] in ["init"]: if args[1] in ["init"]:
try: try:
nvexpo.init(args[2]) nvexpo.init(args[2])
@ -28,7 +32,7 @@ def main() -> int:
variables = {} variables = {}
for raw_var in raw_vars: for raw_var in raw_vars:
if "=" not in raw_var: if "=" not in raw_var:
nvexpo.show_help('Use the syntax "key=value"') nvexpo.show_help("Use the syntax \"key=value\"")
return 1 return 1
try: try:
key, value = raw_var.split("=", 1) key, value = raw_var.split("=", 1)
@ -45,7 +49,7 @@ def main() -> int:
nvexpo.show_help("Empty value") nvexpo.show_help("Empty value")
return 1 return 1
if not re.match(CONSTS.VARNAME_PATTERN, key): if not re.match(CONSTS.VARNAME_PATTERN, key):
nvexpo.show_help(f'"{key}" is not a valid name') nvexpo.show_help(f"\"{key}\" is not a valid name")
return 1 return 1
nvexpo.set_env(variables) nvexpo.set_env(variables)
return 0 return 0

View File

@ -1,12 +1,9 @@
[tool.poetry] [tool.poetry]
name = "nvexpo" name = "nvexpo"
version = "0.1.1" version = "0.1.0"
description = "" description = ""
authors = ["kirbylife <kirbylife@protonmail.com>"] authors = ["kirbylife <kirbylife@protonmail.com>"]
readme = "README.md" readme = "README.md"
license = "MIT"
repository = "https://git.kirbylife.dev/kirbylife/nvexpo"
keywords = ["cli", "bash", "export", "env var"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
@ -23,10 +20,11 @@ format = "ruff format nvexpo"
linter = "ruff nvexpo" linter = "ruff nvexpo"
typing = "mypy nvexpo" typing = "mypy nvexpo"
[tool.ruff] [tool.ruff]
target-version = "py38" target-version = "py38"
line-length = 120 line-length=120
indent-width = 4 indent-width=4
[tool.ruff.lint] [tool.ruff.lint]
select = ["ALL"] select = ["ALL"]
@ -41,11 +39,7 @@ ignore = [
"PLR2004", "PLR2004",
"FA102", "FA102",
"PLW2901", "PLW2901",
"N812", "N812"
"C901",
"PLR0912",
"D213",
"D211"
] ]
fixable = ["ALL"] fixable = ["ALL"]

1
test.env 100644
View File

@ -0,0 +1 @@
HELLO=10