Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep notation #46

Merged
merged 10 commits into from
Jul 11, 2021
4 changes: 4 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Good variable names which should always be accepted.
# We have to go with this because they haven't fixed this yet:
# https://github.com/PyCQA/pylint/issues/2018
good-names=x
181 changes: 93 additions & 88 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyroll"
version = "2.0.0"
version = "2.1.0"
description = "Dice roller with all of the features you could want."
authors = ["Derek 'Vlek' McCammond <[email protected]>"]
license = "gpl-3.0"
Expand Down Expand Up @@ -35,4 +35,4 @@ requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.poetry.scripts]
roll = 'roll.click_dice:roll_cli'
roll = 'roll.click.click_dice:roll_cli'
2 changes: 1 addition & 1 deletion roll/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .roll import roll
from roll.roll import roll
Empty file added roll/click/__init__.py
Empty file.
23 changes: 15 additions & 8 deletions roll/click_dice.py → roll/click/click_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

from typing import List, Union

import click

import roll.parser.operations as ops
from roll import roll
from roll.diceparser import EvaluationResults, RollOption
from roll.parser.types import EvaluationResults, RollOption

import click


@click.command()
Expand Down Expand Up @@ -57,18 +58,24 @@ def roll_cli(expression: List[str] = None,
"""
command_input = ' '.join(expression) if expression is not None else ''

# Because of how we are now evaluating during parsing, we have to go back
# to the old way of having some globalish variable for handing off the
# type of roll that we're attempting to do.
ops.ROLL_TYPE = roll_option

result: Union[int, float, EvaluationResults] = roll(
command_input, verbose, roll_option,
)

if verbose and isinstance(result, dict):
for r in result['rolls']:
if verbose and isinstance(result, EvaluationResults):
for r in result.rolls:
click.echo(
f"{r['dice']}: {r['rolls']}"
f"{r.dice}: {r.rolls}"
)

click.echo(result['total'])

click.echo(result.total)
elif isinstance(result, EvaluationResults):
click.echo(result.total)
else:
click.echo(result)

Expand Down
Loading