ussserrr / stm32pio

Automate managing of STM32CubeMX + PlatformIO projects
https://pypi.org/project/stm32pio
Other
224 stars 24 forks source link

Let CLI tools describe their validators themselves #105

Open ussserrr opened 2 years ago

ussserrr commented 2 years ago

Currently, validation process of some tool is described completely separately of its class (PlatformIO and CubeMX, Java can be treated as a part of CubeMX actually):

return ToolsValidationResults(
    Tool(name=param,
         command=config.get('app', param),
         runner=runner,
         required=required,
         logger=logger).validate()
    for param, runner, required in [
        ('platformio_cmd', platformio_runner, True),
        ('cubemx_cmd', cubemx_runner, True),
        ('java_cmd', java_runner, False)
    ])

We can define some IVerifiable interface that a tool should implement by having a tool.validator attribute which in turn absorbs all related logic. In such configuration, adding a new tool will automatically register it in the virtual "pool" of verifiable instruments.