Skip to content

Add --help and fallback to CLI interface #4765

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions arduino-core/src/processing/app/helpers/CommandlineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class CommandlineParser {

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

private final String value;

Expand Down Expand Up @@ -52,6 +52,7 @@ public CommandlineParser(String[] args) {
actions.put("--get-pref", ACTION.GET_PREF);
actions.put("--install-boards", ACTION.INSTALL_BOARD);
actions.put("--install-library", ACTION.INSTALL_LIBRARY);
actions.put("--help", ACTION.HELP);
}

public void parseArgumentsPhase1() {
Expand Down Expand Up @@ -84,6 +85,14 @@ public void parseArgumentsPhase1() {
}
libraryToInstall = args[i];
}
if (a == ACTION.HELP) {
Set<String> strings = actions.keySet();
String[] valid = strings.toArray(new String[strings.size()]);
String actions = PApplet.join(valid, "\n");
String actionFilemame = "FILE.ino";
String mess = I18n.format(tr("Actions:\n{0}\n{1}"), actionFilemame, actions);
BaseNoGui.showError(null, mess, 3);
}
action = a;
continue;
}
Expand Down Expand Up @@ -185,7 +194,7 @@ public void parseArgumentsPhase1() {
continue;
}
if (args[i].startsWith("--"))
BaseNoGui.showError(null, I18n.format(tr("unknown option: {0}"), args[i]), 3);
BaseNoGui.showError(null, I18n.format(tr("unknown action/option: {0}, use --help"), args[i]), 3);

filenames.add(args[i]);
}
Expand Down
7 changes: 6 additions & 1 deletion build/shared/manpage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ SYNOPSIS

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

*arduino* [*--help*]

DESCRIPTION
-----------
The 'arduino' integrated development environment allows editing,
Expand Down Expand Up @@ -63,7 +65,7 @@ meaning it is pretty useless if you want any feedback or to be able to keep log
automated testing, etc.

ACTIONS

-------
*--verify*::
Build the sketch.

Expand All @@ -83,6 +85,9 @@ ACTIONS
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.
Multiple libraries can be specified, separated by a comma.

*--help*::
Shows list of available actions.

OPTIONS
-------
*--board* __package__:__arch__:__board__[:__parameters__]::
Expand Down