:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(hogli): accept numbers in devenv wizard exclude prompt (#58952)
Jovan Sakovic917b49b67543
diff --git a/tools/hogli-commands/hogli_commands/devenv/wizard.py b/tools/hogli-commands/hogli_commands/devenv/wizard.pyindex a379c09db1fd..bc6e8807cddf 100644--- a/tools/hogli-commands/hogli_commands/devenv/wizard.py+++ b/tools/hogli-commands/hogli_commands/devenv/wizard.py@@ -195,17 +195,20 @@ def _configure_overrides(config: DevenvConfig, registry, resolver: IntentResolveclick.echo("")click.echo(click.style("Processes that will start:", fg="cyan"))- for unit in units_list:+ for i, unit in enumerate(units_list, 1):if unit in manual_start:- click.echo(f" {unit} (manual start)")+ click.echo(f" {i:2}. {unit} (manual start)")else:- click.echo(f" {unit}")+ click.echo(f" {i:2}. {unit}")click.echo("")- click.echo("Units to exclude (enter names from above, or blank to skip):")+ click.echo("Units to exclude (enter numbers or names from above, or blank to skip):")exclude = click.prompt("Comma-separated", default="")- if exclude.strip():- config.exclude_units = [u.strip() for u in exclude.split(",") if u.strip()]+ excluded, out_of_range = _parse_exclude_input(exclude, units_list)+ for idx in out_of_range:+ click.echo(f" Ignoring out-of-range number: {idx}")+ if excluded:+ config.exclude_units = excluded# Ask about manual-start processes (those with ask_skip: true)ask_skip_processes = registry.get_ask_skip_processes()@@ -215,3 +218,27 @@ def _configure_overrides(config: DevenvConfig, registry, resolver: IntentResolveconfig.enable_autostart.append(process_name)return config+++def _parse_exclude_input(raw: str, units: list[str]) -> tuple[list[str], list[int]]:+ """Parse the 'Units to exclude' prompt input.++ Returns (resolved unit names, out-of-range numbers seen). A token that+ parses as a digit is treated as a 1-based index into `units`; anything+ else is passed through as a name.+ """+ excluded: list[str] = []+ out_of_range: list[int] = []+ for token in raw.split(","):+ token = token.strip()+ if not token:+ continue+ if token.isdecimal():+ idx = int(token)+ if 1 <= idx <= len(units):+ excluded.append(units[idx - 1])+ else:+ out_of_range.append(idx)+ else:+ excluded.append(token)+ return excluded, out_of_rangediff --git a/tools/hogli-commands/hogli_commands/tests/test_devenv.py b/tools/hogli-commands/hogli_commands/tests/test_devenv.pyindex baad5ac39160..054f70ed421f 100644--- a/tools/hogli-commands/hogli_commands/tests/test_devenv.py+++ b/tools/hogli-commands/hogli_commands/tests/test_devenv.py@@ -12,6 +12,7 @@ import yamlfrom hogli_commands.devenv.generator import DevenvConfig, MprocsGenerator, load_devenv_configfrom hogli_commands.devenv.registry import ProcessRegistry, create_mprocs_registryfrom hogli_commands.devenv.resolver import Capability, Intent, IntentMap, IntentResolver, load_intent_map+from hogli_commands.devenv.wizard import _parse_exclude_inputfrom parameterized import parameterized@@ -738,3 +739,30 @@ class TestPersonhogEnvInjection:assert var in shell, f"{var} should be in {proc_name} shell"else:assert var not in shell, f"{var} should not be in {proc_name} shell"+++class TestParseExcludeInput:+ """The 'Units to exclude' prompt accepts numbers and/or names."""++ UNITS = ["backend", "docker-compose", "feature-flags", "frontend", "migrate-postgres"]++ @parameterized.expand(+ [+ ("3", ["feature-flags"], []),+ ("feature-flags", ["feature-flags"], []),+ ("1,3", ["backend", "feature-flags"], []),+ ("1, feature-flags", ["backend", "feature-flags"], []),+ (" 3 , 1 ", ["feature-flags", "backend"], []),+ ("", [], []),+ (" ", [], []),+ (" , , ", [], []),+ ("99", [], [99]),+ ("99, feature-flags", ["feature-flags"], [99]),+ ("1, backend", ["backend", "backend"], []),+ ("²", ["²"], []),+ ]+ )+ def test_parse(self, raw: str, expected_excluded: list[str], expected_out_of_range: list[int]) -> None:+ excluded, out_of_range = _parse_exclude_input(raw, self.UNITS)+ assert excluded == expected_excluded+ assert out_of_range == expected_out_of_range