🩹 👔 Add missing vote subcommand
This commit is contained in:
parent
f6a07e69e0
commit
6298b84630
2 changed files with 16 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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)
|
Loading…
Add table
Reference in a new issue