Class CommandLine
java.lang.Object
ch.autumo.ui.utils.CommandLine
Generic command-line handling for an autumo-ui application.
An application accepts a file to open in two shapes:
--open <file>— the explicit form;<file>— the bare file path a packaged (jpackage) launcher receives when the user double-clicks a registered file or uses Open With. The OS hands the selected file straight to the application as the first argument, so no option is present.
A bare argument is only treated as a file when its name carries one of the
registered extensions. The framework registers none by itself: an application declares
which file endings it can open via
BaseApp.registerOpenExtension(String). Without any registration no bare
argument is ever accepted, so unrelated arguments (JavaFX or JVM options) are never mistaken
for a file. The explicit --open form accepts any path, because the intent is then
unambiguous.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringOption that explicitly names the file to open. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasExtension(String name, Collection<String> extensions) Whether a file name carries one of the given extensions.static PathopenTarget(List<String> args, Collection<String> extensions) Picks the file to open from the raw command line arguments.
-
Field Details
-
OPEN_OPTION
-
-
Method Details
-
hasExtension
Whether a file name carries one of the given extensions.- Parameters:
name- file name or path to inspect (may benull)extensions- registered extensions, each with a leading dot (e.g.".ifcx"); may benullor empty, in which case nothing matches- Returns:
trueif the name ends with one of the extensions (case-insensitive)
-
openTarget
Picks the file to open from the raw command line arguments.Recognises
--open <file>and a bare<file>whose extension is registered (see the class comment). Any other argument — notably one starting with-such as--verbose— yieldsnull, so the caller can keep handling its own options.- Parameters:
args- raw command line arguments (may benullor empty)extensions- registered extensions, each with a leading dot; may benullor empty- Returns:
- the file to open, or
nullwhen the command line carries none
-