2022-05-26 14:47:36 +02:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
2022-05-26 15:29:49 +02:00
|
|
|
from unittests_cli.constants import CLI_PATH
|
|
|
|
|
2022-05-26 14:47:36 +02:00
|
|
|
|
|
|
|
class CLICommands:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _run(cmd: str, *args):
|
|
|
|
env_vars = os.environ
|
2022-05-26 22:21:16 +02:00
|
|
|
env_vars['CPL_IS_UNITTEST'] = 'YES'
|
2022-05-26 15:29:49 +02:00
|
|
|
command = ['python', CLI_PATH, cmd]
|
2022-05-26 14:47:36 +02:00
|
|
|
for arg in args:
|
|
|
|
command.append(arg)
|
|
|
|
|
|
|
|
subprocess.run(command, env=env_vars)
|
|
|
|
|
|
|
|
@classmethod
|
2022-05-26 21:42:43 +02:00
|
|
|
def generate(cls, schematic: str, name: str):
|
|
|
|
cls._run('generate', schematic, name)
|
2022-05-26 14:47:36 +02:00
|
|
|
|
|
|
|
@classmethod
|
2022-05-26 21:42:43 +02:00
|
|
|
def new(cls, project_type: str, name: str, *args):
|
|
|
|
cls._run('new', project_type, name, *args)
|