-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2354 from opencb/TASK-5055
TASK-5055 - ERROR CLI Opencga-enterprise
- Loading branch information
Showing
83 changed files
with
363 additions
and
104 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
56 changes: 56 additions & 0 deletions
56
opencga-app/src/main/java/org/opencb/opencga/app/cli/config/CliCategory.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,56 @@ | ||
package org.opencb.opencga.app.cli.config; | ||
|
||
import java.util.Arrays; | ||
|
||
public class CliCategory { | ||
|
||
private String name; | ||
private String description; | ||
private String[] options; | ||
|
||
public CliCategory() { | ||
} | ||
|
||
public CliCategory(String name, String description, String[] options) { | ||
this.name = name; | ||
this.description = description; | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("Category{"); | ||
sb.append("name='").append(name).append('\''); | ||
sb.append(", description='").append(description).append('\''); | ||
sb.append(", options=").append(Arrays.toString(options)); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public CliCategory setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public CliCategory setDescription(String description) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
public String[] getOptions() { | ||
return options; | ||
} | ||
|
||
public CliCategory setOptions(String[] options) { | ||
this.options = options; | ||
return this; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
opencga-app/src/main/java/org/opencb/opencga/app/cli/config/CliConfiguration.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,75 @@ | ||
package org.opencb.opencga.app.cli.config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UncheckedIOException; | ||
|
||
public class CliConfiguration { | ||
|
||
/** | ||
* The instance of Configuration that this Class is storing | ||
*/ | ||
private static CliConfiguration instance; | ||
|
||
/** | ||
* The instance of Usage that stores the "usage" information | ||
*/ | ||
private CliUsage cliUsage; | ||
|
||
/** | ||
* FILENAME is the file location of the configuration yml file | ||
*/ | ||
private String cliUsageFileName = "cli-usage.yml"; | ||
|
||
/** | ||
* LOGGER is an instance of the Logger class so that we can do proper | ||
* logging | ||
*/ | ||
private static final Logger logger = LoggerFactory.getLogger(CliConfiguration.class); | ||
|
||
public static CliConfiguration getInstance() { | ||
if (CliConfiguration.instance == null) { | ||
CliConfiguration.instance = new CliConfiguration(); | ||
} | ||
return CliConfiguration.instance; | ||
} | ||
|
||
private CliUsage loadConfiguration() throws IOException { | ||
try (InputStream is = getClass().getClassLoader().getResourceAsStream(cliUsageFileName)) { | ||
// Mapping the config from the YAML file to the Configuration class | ||
ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); | ||
return yamlObjectMapper.readValue(is, CliUsage.class); | ||
} | ||
} | ||
|
||
/* | ||
* We keep an instance of cliUsage for the Shell | ||
*/ | ||
public CliUsage getUsage() { | ||
if (cliUsage == null) { | ||
try { | ||
cliUsage = loadConfiguration(); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
return cliUsage; | ||
} | ||
|
||
public void setUsage(CliUsage cliUsage) { | ||
this.cliUsage = cliUsage; | ||
} | ||
|
||
public String getCliUsageFileName() { | ||
return cliUsageFileName; | ||
} | ||
|
||
public void setCliUsageFileName(String cliUsageFileName) { | ||
this.cliUsageFileName = cliUsageFileName; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
opencga-app/src/main/java/org/opencb/opencga/app/cli/config/CliUsage.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,32 @@ | ||
package org.opencb.opencga.app.cli.config; | ||
|
||
import java.util.Arrays; | ||
|
||
public class CliUsage { | ||
|
||
CliCategory[] categories; | ||
|
||
public CliUsage() { | ||
} | ||
|
||
public CliUsage(CliCategory[] categories) { | ||
this.categories = categories; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("Usage{"); | ||
sb.append("categories=").append(Arrays.toString(categories)); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
|
||
public CliCategory[] getCategories() { | ||
return categories; | ||
} | ||
|
||
public CliUsage setCategories(CliCategory[] categories) { | ||
this.categories = categories; | ||
return this; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpenCgaCompleter.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
2 changes: 1 addition & 1 deletion
2
opencga-app/src/main/java/org/opencb/opencga/app/cli/main/OpencgaCliOptionsParser.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
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
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
Oops, something went wrong.