Allow to pass project file path to run command instead project dir

This commit is contained in:
Ivan Kravets
2016-08-27 20:32:21 +03:00
parent 7b474c69ab
commit 6894d2c5d2
2 changed files with 18 additions and 1 deletions

View File

@ -38,7 +38,7 @@ from platformio.managers.platform import PlatformFactory
default=getcwd,
type=click.Path(
exists=True,
file_okay=False,
file_okay=True,
dir_okay=True,
writable=True,
resolve_path=True))
@ -54,6 +54,13 @@ def cli(ctx, # pylint: disable=R0913,R0914
silent,
verbose,
disable_auto_clean):
# find project directory on upper level
if isfile(project_dir):
project_dir = util.find_project_dir_above(project_dir)
if not util.is_platformio_project(project_dir):
raise exception.NotPlatformIOProject(project_dir)
with util.cd(project_dir):
# clean obsolete .pioenvs dir
if not disable_auto_clean:

View File

@ -194,6 +194,16 @@ def get_project_dir():
return os.getcwd()
def find_project_dir_above(path):
if isfile(path):
path = dirname(path)
if is_platformio_project(path):
return path
if isdir(dirname(path)):
return find_project_dir_above(dirname(path))
return None
def is_platformio_project(project_dir=None):
if not project_dir:
project_dir = get_project_dir()