Skip to content

Commit 6d6c0e7

Browse files
committed
The are changes for issue 4709.
I improved user friendliness of command line - 1) I added "--help" action, which shows available actions. 2) When non valid action/option used, a message is shown to user to use --help. 30 Updated man page.
1 parent 219e540 commit 6d6c0e7

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

arduino-core/src/processing/app/helpers/CommandlineParser.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class CommandlineParser {
1717

1818
private enum ACTION {
19-
GUI, NOOP, VERIFY("--verify"), UPLOAD("--upload"), GET_PREF("--get-pref"), INSTALL_BOARD("--install-boards"), INSTALL_LIBRARY("--install-library");
19+
GUI, NOOP, VERIFY("--verify"), UPLOAD("--upload"), GET_PREF("--get-pref"), INSTALL_BOARD("--install-boards"), INSTALL_LIBRARY("--install-library"), HELP("--help");
2020

2121
private final String value;
2222

@@ -52,6 +52,7 @@ public CommandlineParser(String[] args) {
5252
actions.put("--get-pref", ACTION.GET_PREF);
5353
actions.put("--install-boards", ACTION.INSTALL_BOARD);
5454
actions.put("--install-library", ACTION.INSTALL_LIBRARY);
55+
actions.put("--help", ACTION.HELP);
5556
}
5657

5758
public void parseArgumentsPhase1() {
@@ -84,6 +85,14 @@ public void parseArgumentsPhase1() {
8485
}
8586
libraryToInstall = args[i];
8687
}
88+
if (a == ACTION.HELP) {
89+
Set<String> strings = actions.keySet();
90+
String[] valid = strings.toArray(new String[strings.size()]);
91+
String actions = PApplet.join(valid, "\n");
92+
String actionFilemame = "FILE.ino";
93+
String mess = I18n.format(tr("Actions:\n{0}\n{1}"), actionFilemame, actions);
94+
BaseNoGui.showError(null, mess, 3);
95+
}
8796
action = a;
8897
continue;
8998
}
@@ -185,7 +194,7 @@ public void parseArgumentsPhase1() {
185194
continue;
186195
}
187196
if (args[i].startsWith("--"))
188-
BaseNoGui.showError(null, I18n.format(tr("unknown option: {0}"), args[i]), 3);
197+
BaseNoGui.showError(null, I18n.format(tr("unknown action/option: {0}, use --help"), args[i]), 3);
189198

190199
filenames.add(args[i]);
191200
}

build/shared/manpage.adoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ SYNOPSIS
3333

3434
*arduino* [*--install-library* __library name__[:__version__][,__library name__[:__version__],__library name__[:__version__]]
3535

36+
*arduino* [*--help*]
37+
3638
DESCRIPTION
3739
-----------
3840
The 'arduino' integrated development environment allows editing,
@@ -63,7 +65,7 @@ meaning it is pretty useless if you want any feedback or to be able to keep log
6365
automated testing, etc.
6466

6567
ACTIONS
66-
68+
-------
6769
*--verify*::
6870
Build the sketch.
6971

@@ -83,6 +85,9 @@ ACTIONS
8385
Fetches available libraries list and install the specified one. If __version__ is omitted, the latest is installed. If a library with the same version is already installed, nothing is installed and program exits with exit code 1. If a library with a different version is already installed, it's replaced.
8486
Multiple libraries can be specified, separated by a comma.
8587

88+
*--help*::
89+
Shows list of available actions.
90+
8691
OPTIONS
8792
-------
8893
*--board* __package__:__arch__:__board__[:__parameters__]::

0 commit comments

Comments
 (0)