Initial commit

main
mat ess 2023-08-09 21:02:53 -04:00
commit 25e4d94c2e
12 changed files with 375 additions and 0 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
dist
*.py[cod]

22
LICENSE.txt Normal file
View File

@ -0,0 +1,22 @@
CECI N'EST PAS UN PERMIS
Copyright mat ess. All rights reserved.
This software may not be used by anyone, for any reason.
As far as the law allows, this software comes as is, without any warranty or condition, and no contributor will be liable to anyone for any damages related to this software or this license, under any kind of legal claim.
===
this is not a license.
free software as envisioned by rms and gnu has failed to defend the freedom of users.
open source software is a tool for corporate cooption, control, and profit.
software should be written for the benefit of the masses.
if you're still reading this: use, change, or share this code however you want. intellectual property is a farce.
https://asternova.top/LICENSE.txt
https://iliana.fyi/treachery
https://www.boringcactus.com/2021/09/29/anti-license-manifesto.html

37
README.md Normal file
View File

@ -0,0 +1,37 @@
# roll
for initiative!
## usage
```bash
$ roll 2d20
1 ..... 15
2 ..... 9
total | 24
$ roll 5d4+2
1 ..... 2
2 ..... 2
3 ..... 4
4 ..... 1
5 ..... 3
mod .. +2
total | 14
$ roll 1d20
1 ..... 1
total | 1
critical miss!
$ roll 1d20+a # or 1d20+advantage
1a .... 19
1b .... 2
total | 19
$ roll
> 1d20
>> total: 12
> +5
>> total + 5: 17
```

174
flake.lock Normal file
View File

@ -0,0 +1,174 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1690933134,
"narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb",
"type": "github"
},
"original": {
"id": "flake-parts",
"type": "indirect"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1691579266,
"narHash": "sha256-Ue2iaxU5VxwjXX6bWv/ElOl35O4+Rk630jBjMqQDRRs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a14013769370b021e23200e7199d8cfaeb97098a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1690881714,
"narHash": "sha256-h/nXluEqdiQHs1oSgkOOWF+j8gcJMWhwnZ9PFabN6q0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9e1960bc196baf6881340d53dccb203a951745a2",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1691397944,
"narHash": "sha256-4fa4bX3kPYKpEssgrFRxRCPVXczidArDeSWaUMSzQAU=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "e5588ddffd4c3578547a86ef40ec9a6fbdae2986",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"pre-commit": "pre-commit"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

54
flake.nix Normal file
View File

@ -0,0 +1,54 @@
{
description = "roll - for initiative!";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.pre-commit.flakeModule
];
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
package = pkgs.python3.pkgs.buildPythonApplication {
pname = "roll";
version = "0.1.0";
src = ./.;
format = "pyproject";
};
in
{
pre-commit.settings.hooks = {
autoflake.enable = true;
black.enable = true;
ruff.enable = true;
pyright.enable = true;
};
packages.default = package;
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
echo "welcome to your python project >~(:)=====--" 1>&2
'';
nativeBuildInputs = builtins.attrValues {
inherit (pkgs)
hatch
;
};
buildInputs = builtins.attrValues {
inherit (pkgs)
autoflake
black
pyright
ruff
;
};
};
};
};
}

66
pyproject.toml Normal file
View File

@ -0,0 +1,66 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "roll"
description = "for initiative!"
readme = "README.md"
requires-python = ">=3.8"
keywords = []
# license-files = { paths = ["LICENSE.txt"] }
authors = [
{ name = "mat ess", email = "mat@mat.services" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"click",
]
dynamic = ["version"]
[project.urls]
Documentation = "https://git.mat.services/mat/roll#readme"
Issues = "https://git.mat.services/mat/roll/issues"
Source = "https://git.mat.services/mat/roll"
[project.scripts]
roll = "roll.cli:roll"
[tool.hatch.envs.default]
dependencies = [
"pytest",
"pytest-cov",
]
[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=roll --cov=tests {args}"
no-cov = "cov --no-cov {args}"
[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]
[tool.hatch.version]
path = "roll/__about__.py"
[tool.coverage.run]
branch = true
parallel = true
omit = [
"roll/__about__.py",
]
[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

1
roll/__about__.py Normal file
View File

@ -0,0 +1 @@
__version__ = "0.1.0"

0
roll/__init__.py Normal file
View File

6
roll/__main__.py Normal file
View File

@ -0,0 +1,6 @@
import sys
if __name__ == "__main__":
from roll.cli import roll
sys.exit(roll())

12
roll/cli/__init__.py Normal file
View File

@ -0,0 +1,12 @@
import click
from roll.__about__ import __version__
@click.group(
context_settings={"help_option_names": ["-h", "--help"]},
invoke_without_command=True,
)
@click.version_option(version=__version__, prog_name="roll")
def roll():
click.echo("Hello world!")

0
tests/__init__.py Normal file
View File