Skip to content
Merged
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
10 changes: 1 addition & 9 deletions jena-cmds/src/main/java/org/apache/jena/cmd/CmdGeneral.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
public abstract class CmdGeneral extends CmdArgModule
{
protected ModGeneral modGeneral = new ModGeneral(this::printHelp);
protected ModVersion modVersion = new ModVersion(true);

protected CmdGeneral(String[] argv) {
super(argv);
addModule(modGeneral);
addModule(modVersion);
}

@Override
Expand All @@ -46,19 +44,13 @@ public void addModule(ArgModuleGeneral argModule) {
public boolean isVerbose() { return modGeneral.verbose; }
public boolean isQuiet() { return modGeneral.quiet; }
public boolean isDebug() { return modGeneral.debug; }
protected boolean help() { return modGeneral.help; }
protected boolean help() { return modGeneral.help; }

final public void printHelp() {
usage();
throw new TerminationException(0);
}

@Override
protected void processModulesAndArgs() {
if ( modVersion.getVersionFlag() )
modVersion.printVersionAndExit();
}

public void add(ArgDecl argDecl, String argName, String msg) {
add(argDecl);
getUsage().addUsage(argName, msg);
Expand Down
9 changes: 9 additions & 0 deletions jena-cmds/src/main/java/org/apache/jena/cmd/CmdMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ public abstract class CmdMain extends CmdGeneral
// gets a chance to create a logger.
static { LogCtl.setLogging(); }

protected ModVersion modVersion = new ModVersion(true);

protected CmdMain(String[] args) {
super(args);
addModule(modVersion);
}

@Override
protected void processModulesAndArgs() {
if ( modVersion.getVersionFlag() )
modVersion.printVersionAndExit();
}

/** Run command - exit on failure */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.function.Consumer;

import org.apache.jena.atlas.lib.Version;
import org.apache.jena.cmd.CmdException;
import org.apache.jena.fuseki.Fuseki;
import org.apache.jena.fuseki.main.FusekiAbortException;
Expand All @@ -32,6 +33,7 @@ class RunFuseki {
// This class wraps an entry point so that it can take control of logging setup.
// This class does not depend via inheritance on any Jena code
// and does not trigger Jena initialization.
//
// FusekiLogging runs before any Jena code can trigger logging setup.
//
// Inheritance causes initialization in the super class first, before class
Expand All @@ -40,6 +42,14 @@ class RunFuseki {
static { FusekiLogging.setLogging(); }

public static void run(String[] args, Consumer<String[]> action) {
if ( args.length == 1) {
String arg = args[0];
if ( "--version".equals(arg) || "-version".equals(arg) ) {
Version.printVersion(System.out, "Fuseki", Version.versionForClass(Fuseki.class));
System.exit(0);
}
}

try {
action.accept(args);
} catch (IllegalArgumentException | CmdException ex ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static FusekiArgs args(FusekiModules fusekiModules, String... args) {
// Execute a step for the argument handlers.
private static void runArgsHandlers( List<? extends FusekiServerArgsHandler> argsHandlers, Consumer<FusekiServerArgsHandler> action) {
for (FusekiServerArgsHandler argsHandler : argsHandlers) {
action.accept( argsHandler);
action.accept(argsHandler);
}
}
// -- Argument handling
Expand Down