From 4b53a99fc93bb62d3e4f7c3a962104aca215a50e Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Sat, 24 Jul 2021 08:37:21 -0700 Subject: [PATCH] simplified scripts with args and added basic docker cmds --- poetry.lock | 6 +++--- pyproject.toml | 10 ++++------ scripts/dev_tools.py | 42 ++++++++++++++++++------------------------ scripts/docker.py | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 scripts/docker.py diff --git a/poetry.lock b/poetry.lock index c9237fa..f685b18 100644 --- a/poetry.lock +++ b/poetry.lock @@ -159,7 +159,7 @@ unicode_backport = ["unicodedata2"] name = "click" version = "8.0.1" description = "Composable command line interface toolkit" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -170,7 +170,7 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.4" description = "Cross-platform colored terminal text." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" @@ -933,7 +933,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "b655f310d9f4a561cd0ad1fb94769d088f90362763251b8500eab116cb9d599c" +content-hash = "54b44cd9c491f5cfd9ffc40d350fac513fb1e63c3c4fd3046aa19f66ebf372d5" [metadata.files] aiohttp = [ diff --git a/pyproject.toml b/pyproject.toml index eec274a..9286296 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ python = "^3.8" web3 = "^5.21.0" pydantic = "^1.8.2" hexbytes = "^0.2.1" +click = "^8.0.1" [tool.poetry.dev-dependencies] pre-commit = "^2.13.0" @@ -29,14 +30,11 @@ build-backend = "poetry.core.masonry.api" lint = 'scripts.dev_tools:lint' test = 'scripts.dev_tools:test' isort = 'scripts.dev_tools:isort' -isortcheck = 'scripts.dev_tools:isortcheck' mypy = 'scripts.dev_tools:mypy' black = 'scripts.dev_tools:black' -blackcheck = 'scripts.dev_tools:blackcheck' -start = 'scripts.dev_tools:start' -start_background = 'scripts.dev_tools:start_background' -stop = 'scripts.dev_tools:stop' -build = 'scripts.dev_tools:build' +start = 'scripts.docker:start' +stop = 'scripts.docker:stop' +build = 'scripts.docker:build' [tool.black] exclude = ''' diff --git a/scripts/dev_tools.py b/scripts/dev_tools.py index b2e4484..a922f53 100644 --- a/scripts/dev_tools.py +++ b/scripts/dev_tools.py @@ -1,4 +1,5 @@ -from subprocess import check_call +import click +from subprocess import check_call, run def lint(): check_call(['pylint', '.']) @@ -6,30 +7,23 @@ def lint(): def test(): check_call(['pytest', '--cov=mev_inspect', 'tests']) -def isort(): - check_call(['isort', '.']) - -def isortcheck(): - check_call(['isort', '--diff', '.']) +@click.command() +@click.option('-c', required=False, is_flag=True) +def isort(c: str): + '''if c is present run isort in diff mode''' + if c: + check_call(['isort', '.']) + else: + check_call(['isort', '--diff', '.']) def mypy(): check_call(['mypy', '.']) -def black(): - check_call(['black', '.']) - -def blackcheck(): - check_call(['black', '--diff', '--color', '.']) - -def start(): - check_call(['docker', 'compose', 'up']) - -def start_background(): - check_call(['docker', 'compose', 'up', '-d']) - -def stop(): - check_call(['docker', 'compose', 'down']) - -def build(): - check_call(['docker', 'compose', 'build']) - +@click.command() +@click.option('-c', required=False, is_flag=True) +def black(c: str): + '''if c is present run black in diff mode''' + if c: + check_call(['black', '.']) + else: + check_call(['black', '--diff', '--color', '.']) diff --git a/scripts/docker.py b/scripts/docker.py new file mode 100644 index 0000000..8da4c39 --- /dev/null +++ b/scripts/docker.py @@ -0,0 +1,19 @@ +import click +from subprocess import check_call, run +from typing import List + +@click.command() +@click.option('-b', required=False, is_flag=True) +def start(b: str): + '''if d is present background compose''' + if b: + check_call(['docker', 'compose', 'up', '-d']) + click.echo('docker running in the background...') + else: + check_call(['docker', 'compose', 'up']) + +def stop(): + check_call(['docker', 'compose', 'down']) + +def build(): + check_call(['docker', 'compose', 'build'])