diff --git a/src/main/java/de/prob2/jupyter/Main.java b/src/main/java/de/prob2/jupyter/Main.java index 4289a0400d977ac67cccba1a84af3782fc5a1335..62b561f9c38e5bc02389b938658ef88ab0363083 100644 --- a/src/main/java/de/prob2/jupyter/Main.java +++ b/src/main/java/de/prob2/jupyter/Main.java @@ -26,9 +26,23 @@ import com.google.inject.Stage; import io.github.spencerpark.jupyter.channels.JupyterConnection; import io.github.spencerpark.jupyter.kernel.KernelConnectionProperties; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public final class Main { + private static final @NotNull String USAGE_TEXT = "Usage: java -jar prob2-jupyter-kernel-all.jar [--help | install [--user] [JUPYTER] | createKernelSpec KERNELSPECDIR | run CONNECTIONFILE]"; + private static final @NotNull String FULL_HELP_TEXT = "--help: Prints this information.\n" + + "\n" + + "install: Copies the kernel into the ProB home directory, and installs the kernel in Jupyter.\n" + + "\tBy default the kernel spec is installed into the sys.prefix of Jupyter's Python installation. If the sys.prefix is not writable (for example when using the system Python installation instead of a virtual environment), the --user flag can be used to install the kernel only for the current user.\n" + + "\tBy default the command \"jupyter\" is used to install the kernel. If the kernel should be installed in a different Jupyter installation, a different Jupyter command can be passed as an argument to the install command.\n" + + "\n" + + "createKernelSpec: Creates a Jupyter kernel spec for this jar file at the given location.\n" + + "\tThis option is for advanced users or developers, who don't want the jar file to be copied, or who want to install the kernel spec manually.\n" + + "\n" + + "run: Runs the kernel using the given connection file.\n" + + "\tThis option is not meant to be used manually, it is used internally when Jupyter starts the kernel."; + private Main() { super(); @@ -211,17 +225,18 @@ public final class Main { } public static void main(final String[] args) throws IOException, InvalidKeyException, NoSuchAlgorithmException { - if (args.length < 1 || args.length == 1 && "--help".equals(args[0])) { - System.err.println("Usage: java -jar prob2-jupyter-kernel-all.jar [--help | install [--user] [JUPYTER] | createKernelSpec KERNELSPECDIR | run CONNECTIONFILE]"); - System.err.println("--help: Prints this information."); - System.err.println("install: Copies the kernel into the ProB home directory, and installs the kernel in Jupyter."); - System.err.println("\tBy default the kernel spec is installed into the sys.prefix of Jupyter's Python installation. If the sys.prefix is not writable (for example when using the system Python installation instead of a virtual environment), the --user flag can be used to install the kernel only for the current user."); - System.err.println("\tBy default the command \"jupyter\" is used to install the kernel. If the kernel should be installed in a different Jupyter installation, a different Jupyter command can be passed as an argument to the install command."); - System.err.println("createKernelSpec: Creates a Jupyter kernel spec for this jar file at the given location."); - System.err.println("\tThis option is for advanced users or developers, who don't want the jar file to be copied, or who want to install the kernel spec manually."); - System.err.println("run: Runs the kernel using the given connection file."); - System.err.println("\tThis option is not meant to be used manually, it is used internally when Jupyter starts the kernel."); + if (args.length < 1) { + System.err.println(USAGE_TEXT); + System.err.println(); + System.err.println("To install the kernel, run: java -jar prob2-jupyter-kernel-all.jar install"); + System.err.println(); + System.err.println("For a full description of all options, run: java -jar prob2-jupyter-kernel-all.jar --help"); throw die(2); + } else if (args.length == 1 && "--help".equals(args[0])) { + System.out.println(USAGE_TEXT); + System.out.println(); + System.out.println(FULL_HELP_TEXT); + throw die(0); } switch (args[0]) { case "install":