Skip to content

Commit f92d8f6

Browse files
committed
address comments
1 parent 10231e0 commit f92d8f6

File tree

12 files changed

+43
-16
lines changed

12 files changed

+43
-16
lines changed

docs/requirements/cli.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
parent: Requirements
3+
---
4+
# CLI
5+
6+
## Unified `--input` option across all commands
7+
`req~jabkit.cli.input-flag~1`
8+
9+
All `jabkit` commands that need a file input must have the `--input` option to specify the input file.
10+
See [ADR 45](../decisions/0045-use-input-flag-always-for-input-files.md) for more details.
11+
12+
Needs: impl
13+
14+
<!-- markdownlint-disable-file MD022 -->

jabkit/src/main/java/org/jabref/cli/CheckConsistency.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CheckConsistency implements Callable<Integer> {
3333
@Mixin
3434
private ArgumentProcessor.SharedOptions sharedOptions = new ArgumentProcessor.SharedOptions();
3535

36+
// [impl->req~jabkit.cli.input-flag~1]
3637
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
3738
private Path inputFile;
3839

jabkit/src/main/java/org/jabref/cli/CheckIntegrity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import static picocli.CommandLine.Command;
2929
import static picocli.CommandLine.Mixin;
3030
import static picocli.CommandLine.Option;
31-
import static picocli.CommandLine.Parameters;
3231

3332
@Command(name = "check-integrity", description = "Check integrity of the database.")
3433
class CheckIntegrity implements Callable<Integer> {
@@ -41,12 +40,14 @@ class CheckIntegrity implements Callable<Integer> {
4140
@Mixin
4241
private ArgumentProcessor.SharedOptions sharedOptions = new ArgumentProcessor.SharedOptions();
4342

44-
@Parameters(converter = CygWinPathConverter.class, description = "BibTeX file to check", arity = "1")
43+
// [impl->req~jabkit.cli.input-flag~1]
44+
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
4545
private Path inputFile;
4646

4747
@Option(names = {"--output-format"}, description = "Output format: errorformat, txt or csv", defaultValue = "errorformat")
4848
private String outputFormat;
4949

50+
// in BibTeX it could be preferences.getEntryEditorPreferences().shouldAllowIntegerEditionBibtex()
5051
@Option(names = {"--allow-integer-edition"}, description = "Allows Integer edition: true or false", defaultValue = "true")
5152
private boolean allowIntegerEdition = true;
5253

jabkit/src/main/java/org/jabref/cli/Convert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class Convert implements Runnable {
3737
@Mixin
3838
private ArgumentProcessor.SharedOptions sharedOptions = new ArgumentProcessor.SharedOptions();
3939

40+
// [impl->req~jabkit.cli.input-flag~1]
4041
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input file", required = true)
4142
private Path inputFile;
4243

jabkit/src/main/java/org/jabref/cli/GenerateBibFromAux.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Optional;
66
import java.util.stream.Collectors;
77

8+
import org.jabref.cli.converter.CygWinPathConverter;
89
import org.jabref.logic.auxparser.AuxParser;
910
import org.jabref.logic.auxparser.AuxParserResult;
1011
import org.jabref.logic.auxparser.AuxParserStatisticsProvider;
@@ -35,8 +36,9 @@ class GenerateBibFromAux implements Runnable {
3536
@Option(names = "--aux", required = true)
3637
private Path auxFile;
3738

38-
@Option(names = "--input", required = true)
39-
private String inputFile;
39+
// [impl->req~jabkit.cli.input-flag~1]
40+
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
41+
private Path inputFile;
4042

4143
@Option(names = "--output")
4244
private Path outputFile;

jabkit/src/main/java/org/jabref/cli/GenerateCitationKeys.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Optional;
55
import java.util.stream.Collectors;
66

7+
import org.jabref.cli.converter.CygWinPathConverter;
78
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
89
import org.jabref.logic.importer.ParserResult;
910
import org.jabref.logic.l10n.Localization;
@@ -28,8 +29,9 @@ public class GenerateCitationKeys implements Runnable {
2829
@Mixin
2930
private ArgumentProcessor.SharedOptions sharedOptions = new ArgumentProcessor.SharedOptions();
3031

31-
@Option(names = "--input", description = "The input .bib file.", required = true)
32-
private String inputFile;
32+
// [impl->req~jabkit.cli.input-flag~1]
33+
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
34+
private Path inputFile;
3335

3436
@Option(names = "--output", description = "The output .bib file.")
3537
private Path outputFile;

jabkit/src/main/java/org/jabref/cli/PdfUpdate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import javax.xml.parsers.ParserConfigurationException;
1010
import javax.xml.transform.TransformerException;
1111

12+
import org.jabref.cli.converter.CygWinPathConverter;
1213
import org.jabref.logic.FilePreferences;
1314
import org.jabref.logic.bibtex.FieldPreferences;
1415
import org.jabref.logic.exporter.EmbeddedBibFilePdfExporter;
@@ -49,8 +50,9 @@ class PdfUpdate implements Runnable {
4950
@Option(names = {"-k", "--citation-key"}, description = "Citation keys", required = true)
5051
private List<String> citationKeys = List.of(); // ToDo: check dedault value
5152

52-
@Option(names = "--input", description = "Input file", required = true)
53-
private Path inputFile; // Local files only
53+
// [impl->req~jabkit.cli.input-flag~1]
54+
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
55+
private Path inputFile;
5456

5557
@Option(names = "--input-format", description = "Input format of the file", required = true)
5658
private String inputFormat = "*";

jabkit/src/main/java/org/jabref/cli/Search.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Search implements Runnable {
4747
@Option(names = {"--query"}, description = "Search query", required = true)
4848
private String query;
4949

50+
// [impl->req~jabkit.cli.input-flag~1]
5051
@Option(names = {"--input"}, converter = CygWinPathConverter.class, description = "Input BibTeX file", required = true)
5152
private Path inputFile;
5253

jablib/src/main/java/org/jabref/logic/importer/ParserResult.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ public Map<BibEntry, Range> getArticleRanges() {
163163
}
164164

165165
public record Range(int startLine, int startColumn, int endLine, int endColumn) {
166-
public static Range getNullRange() {
167-
return new Range(0, 0, 0, 0);
168-
}
166+
public static final Range NULL_RANGE = new Range(0, 0, 0, 0);
169167
}
170168
}

jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public class BibtexParser implements Parser {
106106
private int line = 1;
107107
private int column = 1;
108108
// Stores the last read column of the highest column number encountered on any line so far.
109+
// The intended data structure is Stack, but it is not used because Java code style checkers complain.
109110
// In basic JDK data structures, there is no size-limited stack. We did not want to include Apache Commons Collections only for "CircularFifoBuffer"
110111
private final Deque<Integer> highestColumns = new ArrayDeque<>();
111112

0 commit comments

Comments
 (0)