Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.toolkit.commands

pack-priv Class InputOption

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.MalformedURLException, java.nio.file.InvalidPathException, .Path, java.sql.SQLException, java.util.Optional, org.jabref.logic.importer.FetcherException, org.jabref.logic.l10n.Localization, org.jabref.logic.net.URLDownload, org.jabref.logic.preferences.CliPreferences, org.jabref.logic.shared.DBMSConnectionUrl, .DatabaseNotSupportedException, .SharedDatabaseExport, org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException, org.jabref.logic.util.URLUtil, org.jabref.logic.util.io.FileUtil, org.jabref.toolkit.exception.ImportServiceException, org.slf4j.Logger, .LoggerFactory, picocli.CommandLine, .CommandLine.ArgGroup, .CommandLine.Option, .CommandLine.Parameters

Reusable input-file argument shared by all jabkit subcommands that read a single file.

The file can be supplied either as a positional argument (jabkit check integrity references.bib) or via the --input option (jabkit check integrity --input references.bib). The positional form is the preferred, idiomatic style; --input is retained as a backward-compatible alias.

Exactly one of the two forms must be given; picocli enforces this at parse time via the required, mutually exclusive ArgGroup.

Both forms also accept an http://, https://, or ftp:// URL, which is downloaded to a local temporary file before being used as the input, and a PostgreSQL connection URL such as postgresql://user:secret@host:5432/library, whose shared library is exported to a temporary .bib file before being used as the input (read-only).

See ADR-0057 (which supersedes ADR-0045) and ADR-0065 for the rationale.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
InputOption.InputSource

--input is a backward-compatible alias here; the positional form and the alias both come from ADR 57, which superseded the --input-only ADR 45.

Field Summary

Modifier and TypeField and Description
private InputOption.InputSource
private static final Logger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Path
getInputFile(CliPreferences preferences)

Returns: the resolved input file, downloading it to a temporary file first if a URL was supplied

private static boolean
isPostgreSqlUrl(String input)

DBMSConnectionUrl#parse is deliberately permissive: it finds a PostgreSQL URL anywhere in a pasted text and also accepts libpq's host=...

private static Path
pack-priv static Path

Returns:

the resolved input file, downloading it to a temporary file first if a URL was supplied
resolveInput
(String input, CliPreferences preferences)

Resolves a single input argument to a local file: a URL is downloaded to a temporary file, anything else is taken as a (possibly Cygwin-style) local path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inputSourceback to summary
private InputOption.InputSource inputSource
Annotations
@ArgGroup
exclusive:true
multiplicity:1
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

InputOptionback to summary
pack-priv InputOption()

Method Detail

getInputFileback to summary
pack-priv Path getInputFile(CliPreferences preferences) throws ImportServiceException
Returns:Path

the resolved input file, downloading it to a temporary file first if a URL was supplied

Exceptions
ImportServiceException:
if a URL was supplied and could not be downloaded
isPostgreSqlUrlback to summary
private static boolean isPostgreSqlUrl(String input)

DBMSConnectionUrl#parse is deliberately permissive: it finds a PostgreSQL URL anywhere in a pasted text and also accepts libpq's host=... dbname=... keyword form, which the GUI needs. On the command line that would swallow local files whose name happens to contain such a fragment, so only an argument that starts with the scheme is offered to it.

pullSharedDatabaseback to summary
private static Path pullSharedDatabase(DBMSConnectionUrl connectionUrl, CliPreferences preferences) throws ImportServiceException
resolveInputback to summary
pack-priv static Path resolveInput(String input, CliPreferences preferences) throws ImportServiceException

Resolves a single input argument to a local file: a URL is downloaded to a temporary file, anything else is taken as a (possibly Cygwin-style) local path.

Commands reading more than one input cannot use this mixin — its ArgGroup binds a single argument — and call this method per input instead.

Returns:Path

the resolved input file, downloading it to a temporary file first if a URL was supplied

Exceptions
ImportServiceException:
if a URL was supplied and could not be downloaded
org.jabref.toolkit.commands back to summary

private Class InputOption.InputSource

extends Object
Class Inheritance

--input is a backward-compatible alias here; the positional form and the alias both come from ADR 57, which superseded the --input-only ADR 45.

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

optionInputback to summary
private String optionInput
Annotations
@Option
names:--input
description:Input file, an http(s)/ftp URL, or a PostgreSQL connection URL (alias for the positional FILE argument).
positionalInputback to summary
private String positionalInput
Annotations
@Parameters
index:0
paramLabel:FILE
description:Input file, an http(s)/ftp URL, or a PostgreSQL connection URL. Alternatively, pass it via --input.

Constructor Detail

InputSourceback to summary
private InputSource()