From 1426e7879397804c2ec506ffaac17cde978c4723 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 3 Oct 2015 15:38:33 +0100 Subject: [PATCH] Show valid environment names when user typed unknown values --- platformio/__init__.py | 2 +- platformio/commands/run.py | 7 +++++-- platformio/exception.py | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 33f6ab52..e181eb57 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 3, 3) +VERSION = (2, 3, "4.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/commands/run.py b/platformio/commands/run.py index daf6ae41..8fdf485b 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -36,9 +36,12 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914 if not config.sections(): raise exception.ProjectEnvsNotAvailable() - unknown = set(environment) - set([s[4:] for s in config.sections()]) + known = set([s[4:] for s in config.sections() + if s.startswith("env:")]) + unknown = set(environment) - known if unknown: - raise exception.UnknownEnvNames(", ".join(unknown)) + raise exception.UnknownEnvNames( + ", ".join(unknown), ", ".join(known)) # clean obsolete .pioenvs dir if not disable_auto_clean: diff --git a/platformio/exception.py b/platformio/exception.py index 84b6aca0..940d41d2 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -104,17 +104,17 @@ class UnsupportedArchiveType(PlatformioException): class ProjectEnvsNotAvailable(PlatformioException): - MESSAGE = "Please setup environments in `platformio.ini` file." + MESSAGE = "Please setup environments in `platformio.ini` file" class InvalidEnvName(PlatformioException): - MESSAGE = "Invalid environment '%s'. The name must start " "with 'env:'." + MESSAGE = "Invalid environment '%s'. The name must start with 'env:'" class UnknownEnvNames(PlatformioException): - MESSAGE = "Unknown environment names '%s'." + MESSAGE = "Unknown environment names '%s'. Valid names are '%s'" class GetSerialPortsError(PlatformioException):