Skip to content

Commit 9378f3b

Browse files
committed
refactor(command): organize user commands in subdir
1 parent 2be5760 commit 9378f3b

File tree

16 files changed

+37
-19
lines changed

16 files changed

+37
-19
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from argparse import Namespace
2+
3+
from compiler_admin.commands.user.create import create # noqa: F401
4+
from compiler_admin.commands.user.convert import convert # noqa: F401
5+
from compiler_admin.commands.user.delete import delete # noqa: F401
6+
from compiler_admin.commands.user.offboard import offboard # noqa: F401
7+
from compiler_admin.commands.user.reset_password import reset_password # noqa: F401
8+
from compiler_admin.commands.user.restore import restore # noqa: F401
9+
from compiler_admin.commands.user.signout import signout # noqa: F401
10+
11+
12+
def user(args: Namespace, *extra):
13+
# try to call the subcommand function directly from local symbols
14+
# if the subcommand function was imported above, it should exist in locals()
15+
if args.subcommand in locals():
16+
locals()[args.subcommand](args, *extra)
17+
else:
18+
raise ValueError(f"Unknown user subcommand: {args.subcommand}")
File renamed without changes.
File renamed without changes.
File renamed without changes.

compiler_admin/commands/offboard.py renamed to compiler_admin/commands/user/offboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from tempfile import NamedTemporaryFile
33

44
from compiler_admin import RESULT_SUCCESS, RESULT_FAILURE
5-
from compiler_admin.commands.delete import delete
6-
from compiler_admin.commands.signout import signout
5+
from compiler_admin.commands.user.delete import delete
6+
from compiler_admin.commands.user.signout import signout
77
from compiler_admin.services.google import (
88
USER_ARCHIVE,
99
CallGAMCommand,

compiler_admin/commands/reset_password.py renamed to compiler_admin/commands/user/reset_password.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from argparse import Namespace
22

33
from compiler_admin import RESULT_SUCCESS, RESULT_FAILURE
4-
from compiler_admin.commands.signout import signout
4+
from compiler_admin.commands.user.signout import signout
55
from compiler_admin.services.google import USER_HELLO, CallGAMCommand, user_account_name, user_exists
66

77

File renamed without changes.
File renamed without changes.

tests/commands/test_convert.py renamed to tests/commands/user/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44
from compiler_admin import RESULT_FAILURE, RESULT_SUCCESS
5-
from compiler_admin.commands.convert import convert, __name__ as MODULE
5+
from compiler_admin.commands.user.convert import convert, __name__ as MODULE
66

77

88
@pytest.fixture

tests/commands/test_create.py renamed to tests/commands/user/test_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44
from compiler_admin import RESULT_FAILURE, RESULT_SUCCESS
5-
from compiler_admin.commands.create import create, __name__ as MODULE
5+
from compiler_admin.commands.user.create import create, __name__ as MODULE
66
from compiler_admin.services.google import USER_HELLO
77

88

0 commit comments

Comments
 (0)