mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 22:56:37 +00:00
[vscode] provide version to editor (#8752)
This commit is contained in:
parent
dded81d622
commit
11dcaf7383
@ -7,6 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
from esphome.config import Config, _format_vol_invalid, validate_config
|
from esphome.config import Config, _format_vol_invalid, validate_config
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
|
from esphome.const import __version__ as ESPHOME_VERSION
|
||||||
from esphome.core import CORE, DocumentRange
|
from esphome.core import CORE, DocumentRange
|
||||||
from esphome.yaml_util import parse_yaml
|
from esphome.yaml_util import parse_yaml
|
||||||
|
|
||||||
@ -97,7 +98,21 @@ def _ace_loader(fname: str) -> dict[str, Any]:
|
|||||||
return parse_yaml(fname, raw_yaml_stream)
|
return parse_yaml(fname, raw_yaml_stream)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_version():
|
||||||
|
"""Print ESPHome version."""
|
||||||
|
print(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"type": "version",
|
||||||
|
"value": ESPHOME_VERSION,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def read_config(args):
|
def read_config(args):
|
||||||
|
_print_version()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
CORE.reset()
|
CORE.reset()
|
||||||
data = json.loads(input())
|
data = json.loads(input())
|
||||||
|
@ -18,8 +18,12 @@ def _run_repl_test(input_data):
|
|||||||
vscode.read_config(args)
|
vscode.read_config(args)
|
||||||
|
|
||||||
# Capture printed output
|
# Capture printed output
|
||||||
full_output = "".join(call[0][0] for call in mock_stdout.write.call_args_list)
|
full_output = "".join(
|
||||||
return full_output.strip().split("\n")
|
call[0][0] for call in mock_stdout.write.call_args_list
|
||||||
|
).strip()
|
||||||
|
splitted_output = full_output.split("\n")
|
||||||
|
remove_version = splitted_output[1:] # remove first entry with version info
|
||||||
|
return remove_version
|
||||||
|
|
||||||
|
|
||||||
def _validate(file_path: str):
|
def _validate(file_path: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user