mirror of
https://github.com/rjNemo/pass-gen
synced 2026-06-06 02:26:42 +00:00
feat: add cli option for length
This commit is contained in:
parent
debe9c4565
commit
fc6779af14
4 changed files with 24 additions and 7 deletions
5
Makefile
5
Makefile
|
|
@ -12,5 +12,8 @@ test:
|
||||||
|
|
||||||
.PHONY: cli
|
.PHONY: cli
|
||||||
cli:
|
cli:
|
||||||
pipenv run python app/main.py
|
pipenv run python -m app.main
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
pipenv run python -m app.main --help
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
## Stories
|
## Stories
|
||||||
|
|
||||||
- [x] As a user I want to generate a random secure password to protect my personal accounts
|
- [x] As a user I want to generate a random secure password to protect my personal accounts
|
||||||
- [ ] Minimal length
|
- [x] Minimal length
|
||||||
- [ ] Include symbols
|
- [ ] Include symbols
|
||||||
- [ ] Include numbers
|
- [ ] Include numbers
|
||||||
- [ ] Include lowercase characters
|
- [ ] Include lowercase characters
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ app = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def main() -> None:
|
def main(
|
||||||
typer.echo(generate_password(0))
|
length: int = typer.Option(8, help="Length of the generated password."),
|
||||||
|
) -> None:
|
||||||
|
typer.echo(generate_password(0, length))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,22 @@
|
||||||
from typer.testing import CliRunner
|
from typer.testing import CliRunner, Result
|
||||||
|
|
||||||
from .main import app
|
from .main import app
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
||||||
|
|
||||||
def test_cli_print_password() -> None:
|
def test_cli_print_password() -> None:
|
||||||
result = runner.invoke(app)
|
result = _run_cli()
|
||||||
assert result.exit_code == 0
|
|
||||||
assert "2yW4AcqG" in result.stdout
|
assert "2yW4AcqG" in result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_can_set_password_length() -> None:
|
||||||
|
args = ["--length", 10]
|
||||||
|
result = _run_cli(*args)
|
||||||
|
assert "2yW4AcqGFz" in result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def _run_cli(*args) -> Result:
|
||||||
|
result = runner.invoke(app, args)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
return result
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue