8000 More commandline improvements by matthijskooijman · Pull Request #2000 · arduino/Arduino · GitHub
[go: up one dir, main page]

Skip to content

More commandline improvements #2000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
92aa64f
Use an "action" enum when processing commandline arguments
matthijskooijman Apr 7, 2014
0453606
Invert decision on when to show the GUI
matthijskooijman Apr 7, 2014
a90cb9d
Improve commandline handling control flow
matthijskooijman Apr 7, 2014
d028a7a
Add Base.selectSerialPort
matthijskooijman Apr 7, 2014
017dc70
Fix indentation in the manpage
matthijskooijman Apr 7, 2014
f1a3442
Added history section to the manpage
matthijskooijman Apr 7, 2014
34f5930
Process some commandline arguments earlier
matthijskooijman Apr 7, 2014
07181de
Error when passing --verbose without --verify or --upload
matthijskooijman Apr 7, 2014
bdc98a9
Explicitely save preferences on startup
matthijskooijman Apr 7, 2014
06416aa
Add --no-save-prefs option
matthijskooijman Apr 7, 2014
0f18e3d
Don't save a new preferences file in Preferences.init
matthijskooijman Apr 7, 2014
c344017
Ensure --verbose is never saved to preferences.txt
matthijskooijman Apr 7, 2014
c27880f
Add --noop option
matthijskooijman Apr 7, 2014
6e8eaff
Add --get-pref option
matthijskooijman Apr 7, 2014
95e33f6
Parse --preferences-file in main instead of Preferences.init
matthijskooijman Apr 8, 2014
e10ecad
Don't re-parse arguments to --preferences-file
matthijskooijman Apr 8, 2014
9249c78
Parse --curdir in Base.main()
matthijskooijman Apr 8, 2014
a087c8e
Pass around sketch File objects instead of filenames
matthijskooijman Apr 8, 2014
0ee6d24
Add Base.absoluteFile method
matthijskooijman Apr 8, 2014
d0a2e94
Fix --curdir on Windows
matthijskooijman Apr 8, 2014
6d54a06
Fix opening a non-primary .ino file
matthijskooijman Apr 8, 2014
d582b73
Take into account --curdir for all relative paths
matthijskooijman Apr 9, 2014
c84edbc
Let Editor::statusError print to stderr
matthijskooijman Dec 5, 2013
ae19b7b
If build.path is specified, create it if needed
matthijskooijman Apr 9, 2014
7f23924
Fix preference directory opening in the GUI with --preferences-file
matthijskooijman Apr 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use an "action" enum when processing commandline arguments
Previously, two separate booleans (doUpload and doVerify) were used.
However, since it always makes sense to specify only one of them, it
makes more sense to keep a single action enum variable, which slightly
simplifies the code (especially when more actions are added later).

Additionally, an error is now shown when both --verify and --upload are
specified on the commandline.
  • Loading branch information
matthijskooijman committed Apr 7, 2014
commit 92aa64f6c25cb2ee381e0e2af29f8d360448bb28
33 changes: 20 additions & 13 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ static protected void initRequirements() {
}


protected static enum ACTION { GUI, VERIFY, UPLOAD };
public Base(String[] args) throws Exception {
platform.init(this);

Expand Down Expand Up @@ -318,23 +319,29 @@ public Base(String[] args) throws Exception {
// Setup board-dependent variables.
onBoardOrPortChange();

boolean doUpload = false;
boolean doVerify = false;
ACTION action = ACTION.GUI;
boolean doVerboseBuild = false;
boolean doVerboseUpload = false;;
String selectBoard = null;
String selectPort = null;
String currentDirectory = System.getProperty("user.dir");
List<String> filenames = new LinkedList<String>();

// Map of possible actions and corresponding options
final Map<String, ACTION> actions = new HashMap<String, ACTION>();
actions.put("--verify", ACTION.VERIFY);
actions.put("--upload", ACTION.UPLOAD);

// Check if any files were passed in on the command line
for (int i = 0; i < args.length; i++) {
if (args[i].equals("--upload")) {
doUpload = true;
continue;
}
if (args[i].equals("--verify")) {
doVerify = true;
ACTION a = actions.get(args[i]);
if (a != null) {
if (action != ACTION.GUI) {
String[] valid = actions.keySet().toArray(new String[0]);
String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
showError(null, mess, 3);
}
action = a;
continue;
}
if (args[i].equals("--verbose") || args[i].equals("-v")) {
Expand Down Expand Up @@ -391,7 +398,7 @@ public Base(String[] args) throws Exception {
filenames.add(args[i]);
}

if ((doUpload || doVerify) && filenames.size() != 1)
if ((action == ACTION.UPLOAD || action == ACTION.VERIFY) && filenames.size() != 1)
showError(null, _("Must specify exactly one sketch file"), 3);

for (String path: filenames) {
Expand All @@ -412,17 +419,17 @@ public Base(String[] args) throws Exception {
path = new File(currentDirectory, path).getAbsolutePath();
}

if (handleOpen(path, nextEditorLocation(), !(doUpload || doVerify)) == null) {
if (handleOpen(path, nextEditorLocation(), !(action == ACTION.UPLOAD || action == ACTION.VERIFY)) == null) {
8195 String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
// Open failure is fatal in upload/verify mode
if (doUpload || doVerify)
if (action == ACTION.VERIFY || action == ACTION.UPLOAD)
showError(null, mess, 2);
else
showWarning(null, mess, null);
}
}

if (doUpload || doVerify) {
if (action == ACTION.UPLOAD || action == ACTION.VERIFY) {
// Set verbosity for command line build
Preferences.set("build.verbose", "" + doVerboseBuild);
Preferences.set("upload.verbose", "" + doVerboseUpload);
Expand All @@ -432,7 +439,7 @@ public Base(String[] args) throws Exception {
// Do board selection if requested
processBoardArgument(selectBoard);

if (doUpload) {
if (action == ACTION.UPLOAD) {
// Build and upload
if (selectPort != null)
editor.selectSerialPort(selectPort);
Expand Down
0