-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a separate base class for command and conda CLI configs.
Right now, the conda CLI config only works on windows.
- Loading branch information
Showing
6 changed files
with
104 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/fiji/plugin/trackmate/util/cli/CommandCLIConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package fiji.plugin.trackmate.util.cli; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Base class for CLI config that are based on an executable, reachable by a | ||
* path. | ||
*/ | ||
public abstract class CommandCLIConfigurator extends CLIConfigurator | ||
{ | ||
|
||
protected final ExecutablePath executable; | ||
|
||
protected CommandCLIConfigurator() | ||
{ | ||
this.executable = new ExecutablePath(); | ||
} | ||
|
||
@Override | ||
public ExecutablePath getCommandArg() | ||
{ | ||
return executable; | ||
} | ||
|
||
protected String checkExecutable() | ||
{ | ||
if ( !executable.isSet() ) | ||
{ | ||
return "Executable path is not set.\n"; | ||
} | ||
else | ||
{ | ||
final String path = executable.getValue(); | ||
final File file = new File( path ); | ||
if ( !file.exists() ) | ||
return "Executable path " + path + " does not exist.\n"; | ||
if ( !file.canExecute() ) | ||
return "Executable " + path + " cannot be run.\n"; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String check() | ||
{ | ||
final String out = checkExecutable(); | ||
if ( out != null ) | ||
return out; | ||
return super.check(); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
final StringBuilder str = new StringBuilder(); | ||
str.append( executable.toString() ); | ||
str.append( super.toString() + "\n" ); | ||
return str.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters