Skip to content

Commit 7bb3167

Browse files
committed
refactor cli
1 parent d979a35 commit 7bb3167

5 files changed

Lines changed: 27 additions & 28 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
entry_points = {
4242
'console_scripts': [
43-
'sopy = sopy.manage:cli.main',
43+
'sopy = sopy.cli:main',
4444
],
4545
},
4646
)

sopy/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if __name__ == '__main__':
2+
from .cli import main
3+
main(as_module=True)

sopy/cli.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
from flask.cli import FlaskGroup
3+
4+
from sopy import create_app
5+
6+
cli = FlaskGroup(create_app=create_app)
7+
8+
9+
def main(as_module=False):
10+
this_module = __package__ + '.cli'
11+
args = sys.argv[1:]
12+
13+
if as_module:
14+
name = 'python -m ' + this_module.rsplit('.', 1)[0]
15+
sys.argv = ['-m', this_module] + sys.argv[1:]
16+
else:
17+
name = None
18+
19+
cli.main(args=args, prog_name=name)
20+
21+
22+
if __name__ == '__main__':
23+
main(as_module=True)

sopy/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
DEBUG = True
21
SECRET_KEY = 'dev'
3-
SERVER_NAME = 'localhost:5000'
42

53
SQLALCHEMY_DATABASE_URI = 'postgresql:///sopy'
64
SQLALCHEMY_TRACK_MODIFICATIONS = False

sopy/manage.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)