🩹 👔 Add missing vote subcommand

This commit is contained in:
Brian Wiborg 2023-04-03 17:36:47 +02:00
parent f6a07e69e0
commit 6298b84630
No known key found for this signature in database
GPG Key ID: BE53FA9286B719D6
2 changed files with 16 additions and 1 deletions

View File

@ -55,6 +55,7 @@ $> voting --help
│ new Create a new voting. │ │ new Create a new voting. │
│ rm Delete a voting. │ │ rm Delete a voting. │
│ show Display the results of a voting. │ │ show Display the results of a voting. │
│ vote Place a vote. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
$> voting new EXAMPLE_TITLE --quorum A:5 --voters a,b,c,d,e,f,g,h,i,j $> voting new EXAMPLE_TITLE --quorum A:5 --voters a,b,c,d,e,f,g,h,i,j

View File

@ -1,7 +1,7 @@
import typer import typer
from arrow import get as arrow_get from arrow import get as arrow_get
from voting import Quorum, QuorumKind, Result, Voting from voting import Quorum, QuorumKind, Result, Voting, Vote
from voting.storage import Storage from voting.storage import Storage
app = typer.Typer() app = typer.Typer()
@ -82,3 +82,17 @@ def show(title: str,
print(f"{vote} => {voting.votes[vote].name}") print(f"{vote} => {voting.votes[vote].name}")
else: else:
print(Result(voting)) print(Result(voting))
@app.command()
def vote(title: str,
vote: str = None,
voter: str = typer.Option("", "--voter", "-V", help="Name of the voter"),
):
"""Place a vote."""
with Storage() as store:
voting = store.pop(title)
if not Voting:
return
voting.vote(voter, Vote[vote])
store.push(voting)