Skip to content

Commit

Permalink
✨ enhancement: Add format @cli.command to format our codebase
Browse files Browse the repository at this point in the history
Closes #129
  • Loading branch information
anselal committed Oct 4, 2018
1 parent 22af542 commit aad0c99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion manage.py
@@ -1,10 +1,13 @@
import subprocess

from flask.cli import FlaskGroup

from antminermonitor.app import create_app
from antminermonitor.extensions import db
from antminermonitor.blueprints.asicminer.models.miner import Miner
from antminermonitor.blueprints.asicminer.models.miner_model import MinerModel
from antminermonitor.blueprints.asicminer.models.settings import Settings
from antminermonitor.blueprints.user.models import User
from antminermonitor.extensions import db

cli = FlaskGroup(create_app=create_app)

Expand Down Expand Up @@ -282,5 +285,18 @@ def create_admin():
print("[INFO] Something went wrong.")


@cli.command()
def format():
"""Runs the yapf and isort formatters over the project."""
isort = 'isort -rc *.py antminermonitor/'
yapf = 'yapf -r -i *.py antminermonitor/'

print('Running {}'.format(isort))
subprocess.call(isort, shell=True)

print('Running {}'.format(yapf))
subprocess.call(yapf, shell=True)


if __name__ == "__main__":
cli()
2 changes: 2 additions & 0 deletions requirements.txt
@@ -1,7 +1,9 @@
isort==4.3.4
Flask==1.0.2
Flask-SQLAlchemy==2.3.0
Flask-Migrate==2.1.1
Flask-Login==0.4.1
Flask-WTF==0.14.2
python-dotenv==0.9.1
WTForms-Components==0.10.3
yapf==0.24.0

0 comments on commit aad0c99

Please sign in to comment.