From 673c484fa789a3c04ee1b4a6af172b86587ad72e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 31 Jan 2015 22:42:52 +0200 Subject: [PATCH] Ask about "auto-uploading" within "platformio init" command --- docs/quickstart.rst | 14 ++++++--- docs/userguide/cmd_init.rst | 40 ++++++++++++++++++-------- platformio/builder/scripts/atmelavr.py | 4 +-- platformio/commands/init.py | 27 +++++++++++++---- 4 files changed, 61 insertions(+), 24 deletions(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 773a416e..1ad7e264 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -19,17 +19,23 @@ Quickstart $ platformio init --board=TYPE_1 --board=TYPE_2 --board=TYPE_N + Would you like to enable firmware auto-uploading when project is successfully built using `platformio run` command? + Don't forget that you can upload firmware manually using `platformio run --target upload` command. [y/N]: y + The current working directory *** will be used for the new project. You can specify another project directory via `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. The next files/directories will be created in *** - `platformio.ini` - Project Configuration File - `src` - a source directory. Put your source code here - `lib` - a directory for the project specific libraries + platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| + src - Put your source code here + lib - Put here project specific or 3-rd party libraries Do you want to continue? [y/N]: y Project has been successfully initialized! - Now you can process it with `platformio run` command. + Useful commands: + `platformio run` - process/build project from the current directory + `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board + `platformio run --target clean` - clean project (remove compiled files) Put your source code ``*.h, *.c, *.cpp or *.ino`` files to ``src`` directory. diff --git a/docs/userguide/cmd_init.rst b/docs/userguide/cmd_init.rst index 295d2b89..4890adf1 100644 --- a/docs/userguide/cmd_init.rst +++ b/docs/userguide/cmd_init.rst @@ -68,12 +68,15 @@ Examples `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. The next files/directories will be created in *** - platformio.ini - Project Configuration File - src - a source directory. Put your source code here - lib - a directory for the project specific libraries + platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| + src - Put your source code here + lib - Put here project specific or 3-rd party libraries Do you want to continue? [y/N]: y Project has been successfully initialized! - Now you can process it with `platformio run` command. + Useful commands: + `platformio run` - process/build project from the current directory + `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board + `platformio run --target clean` - clean project (remove compiled files) 2. Create new project in the specified directory @@ -83,12 +86,15 @@ Examples $ platformio init -d %PATH_TO_DIR% The next files/directories will be created in *** - platformio.ini - Project Configuration File - src - a source directory. Put your source code here - lib - a directory for the project specific libraries + platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| + src - Put your source code here + lib - Put here project specific or 3-rd party libraries Do you want to continue? [y/N]: y Project has been successfully initialized! - Now you can process it with `platformio run` command. + Useful commands: + `platformio run` - process/build project from the current directory + `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board + `platformio run --target clean` - clean project (remove compiled files) 3. Initialise project for Arduino Uno @@ -96,10 +102,20 @@ Examples $ platformio init --board uno + Would you like to enable firmware auto-uploading when project is successfully built using `platformio run` command? + Don't forget that you can upload firmware manually using `platformio run --target upload` command. [y/N]: y + + The current working directory *** will be used for the new project. + You can specify another project directory via + `platformio init -d %PATH_TO_THE_PROJECT_DIR%` command. + The next files/directories will be created in *** - platformio.ini - Project Configuration File - src - a source directory. Put your source code here - lib - a directory for the project specific libraries + platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-| + src - Put your source code here + lib - Put here project specific or 3-rd party libraries Do you want to continue? [y/N]: y Project has been successfully initialized! - Now you can process it with `platformio run` command. + Useful commands: + `platformio run` - process/build project from the current directory + `platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board + `platformio run --target clean` - clean project (remove compiled files) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 705f3e67..16734e4c 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -190,8 +190,8 @@ if is_uptarget: break if "UPLOAD_PORT" not in env: - Exit("Please specify environment 'upload_port' or use global " - "--upload-port option.") + print("WARNING!!! Please specify environment 'upload_port' or use " + "global --upload-port option.\n") # # Setup default targets diff --git a/platformio/commands/init.py b/platformio/commands/init.py index f81cf5e4..31dc7a39 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -30,8 +30,17 @@ def cli(project_dir, board, disable_auto_uploading): if board and not set(board).issubset(builtin_boards): raise UnknownBoard(", ".join(set(board).difference(builtin_boards))) + # ask about auto-uploading + if board and app.get_setting("enable_prompts"): + disable_auto_uploading = not click.confirm( + "\nWould you like to enable firmware auto-uploading when project " + "is successfully built using `platformio run` command? \n" + "Don't forget that you can upload firmware manually using " + "`platformio run --target upload` command." + ) + if project_dir == getcwd(): - click.secho("The current working directory", fg="yellow", nl=False) + click.secho("\nThe current working directory", fg="yellow", nl=False) click.secho(" %s " % project_dir, fg="cyan", nl=False) click.secho( "will be used for the new project.\n" @@ -42,15 +51,16 @@ def cli(project_dir, board, disable_auto_uploading): click.echo("The next files/directories will be created in %s" % click.style(project_dir, fg="cyan")) - click.echo("%s - Project Configuration File" % + click.echo("%s - Project Configuration File. |-> PLEASE EDIT ME <-|" % click.style("platformio.ini", fg="cyan")) - click.echo("%s - a source directory. Put your source code here" % + click.echo("%s - Put your source code here" % click.style("src", fg="cyan")) - click.echo("%s - a directory for the project specific libraries" % + click.echo("%s - Put here project specific or 3-rd party libraries" % click.style("lib", fg="cyan")) if (not app.get_setting("enable_prompts") or click.confirm("Do you want to continue?")): + for d in (src_dir, lib_dir): if not isdir(d): makedirs(d) @@ -60,8 +70,13 @@ def cli(project_dir, board, disable_auto_uploading): if board: fill_project_envs(project_file, board, disable_auto_uploading) click.secho( - "Project has been successfully initialized!\n" - "Now you can process it with `platformio run` command.", + "Project has been successfully initialized!\nUseful commands:\n" + "`platformio run` - process/build project from the current " + "directory\n" + "`platformio run --target upload` or `platformio run -t upload` " + "- upload firmware to embedded board\n" + "`platformio run --target clean` - clean project (remove compiled " + "files)", fg="green" ) else: