def __init__(self): self.path = os.getcwd() self.argv = sys.argv[1:] if len(self.argv) < 3: print(console_help) return self.command, self.object, self.name = self.argv if self.command not in COMMAND: print(bad_command.format(self.command)) return if self.object not in OBJECT: print(bad_object.format(self.object)) return if self.name in os.listdir(self.path) and self.command == 'create': print(bad_name.format(self.name)) return try: obj = getattr(aioframe.core, self.object)(self.name, self.path) getattr(obj, self.command)() except Exception as e: print(e)
def test_process_command_exist_name(self): with open('test_exist', 'w') as f: f.write('test_exist') _help = subprocess.check_output(['aioframe create project test_exist'], shell=True) assert _help == bad_name.format('test_exist').encode() + b'\n' os.remove('test_exist')