Skip to content

Commit

Permalink
Improved help information
Browse files Browse the repository at this point in the history
Expand help information to be more descriptive for users.
  • Loading branch information
jordanpadams committed Nov 1, 2023
1 parent 6403dd4 commit d6b5ed4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
47 changes: 36 additions & 11 deletions src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public class CommandLineInterface {
public CommandLineInterface() {
super();
this.opts = new Options();
this.opts.addOption(Option.builder("A").argName("auth-file").desc(
"file with the URL and credential content to have full (all product states) read-only access to the registry API")
.hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build());

// Disabling this argument for the time being since the Search API does not yet support authorized access
// this.opts.addOption(Option.builder("A").argName("auth-file").desc(
// "file with the URL and credential content to have full (all product states) read-only access to the Registry Search API")
// .hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build());

this.opts.addOption(Option.builder("a").argName("auth-file").desc(
"file with the URL and credential content to have full, direct read-only access to the search DB")
"file with the URL and credential content to have full, direct read-only access to the Registry OpenSearch DB")
.hasArg(true).longOpt("auth-opensearch").numberOfArgs(1).optionalArg(true).build());
this.opts.addOption(Option.builder("h").desc("show this text and exit").hasArg(false)
.longOpt("help").optionalArg(true).build());
Expand All @@ -41,9 +44,25 @@ public CommandLineInterface() {

public void help() {
new HelpFormatter().printHelp("ValidateReferenceIntegrity",
"\nChecks the search DB that all references exist. If the api-auth is provided, then it will also check that the registry API also finds all the references.\n\nAll arguments are either a lidvid, label, or manifest file.\n A lidvid must start with urn:nasa:pds:.\n A label must be a well formed PDS XML file.\n A manifest file is one item per line with an item being a lidvid or label. Each line must be terminated by a LF.\n\nMultiple arguments may be given in any order: 'urn:nasa:pds:foo::1.0 label.xml urn:nasa:pds:bar::2.0 manifest.txt'.\n\n",
"\nChecks that (1) all product references within a given product and " +
"(2) any aggregrate product references (bundles -> collections -> products) " +
"exist in the Registry OpenSearch DB or Search API. \n\n" +
"Expected positional arguments are either a lidvid, label, or manifest file.\n" +
" * A lidvid must start with urn:.\n" +
" * A label must be a well formed PDS XML file.\n" +
" * A manifest file is one item per line with an item being a lidvid or label. Each line must be terminated by a LF.\n\n" +
"Multiple arguments may be given in any order, for example:\n" +
" > validate-refs urn:nasa:pds:foo::1.0 label.xml urn:nasa:pds:bar::2.0 manifest.txt\n\n",
opts,
"\nAn auth-file is either a text file of the Java property format with two variables: 'url' and 'credentials'. The 'url' property should be the complete base URL to the Registry Search endpoint or Search API, e.g. 'https://localhost:9876/base', and 'credentials' a path to a java property file with the user name, password, and other credential information as that used by harvest. Or it is an XML text file used by harvest with <registry> containing the 'auth' attribute.\n\n",
"\nAn auth-file is either a text file of the Java property format " +
"with two variables: 'url' and 'credentials'. \n" +
" * The 'url' property is the complete base URL to the Registry OpenSearch endpoint or Search API, e.g. 'https://my-registry.es.amazonaws.com/_search', and " +
" * The 'credentials' is the path to:" +
" * Harvest config file containing the necessary Registry OpenSearch authorization" +
" <registry url=\"http://localhost:9200\" index=\"registry\" auth=\"/path/to/auth.cfg\" />"
" * Java Properties file with a 'user' and 'password' specified, for example: " +
" user=janedoe"
" password=mypassword\n\n"
true);
}

Expand All @@ -68,13 +87,19 @@ public int process(String[] args)
if (cl.hasOption("verbose"))
loggerConfig.setLevel(Level.INFO);
ctx.updateLoggers();
if (!cl.hasOption("a"))
throw new ParseException(
"Not yet implemented. Must provide OpenSearch Registry authorization information.");

// Disabling this argument for the time being since the Search API does not yet support authorized access
// this.opts.addOption(Option.builder("A").argName("auth-file").desc(
// "file with the URL and credential content to have full (all product states) read-only access to the Registry Search API")
// .hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build());
// if (!cl.hasOption("a"))
// throw new ParseException(
// "Not yet implemented. Must provide OpenSearch Registry authorization information.");

if (cl.getArgList().size() < 1)
throw new ParseException("Must provide at least one LIDVID as a starting point.");
throw new ParseException("Must provide at least one LIDVID, Label file path, or manifest file path as a starting point.");
if (!cl.hasOption("A"))
log.warn("Using OpenSearch Registry to check references.");
log.warn("Using Registry OpenSearch Database to check references.");

if (cl.hasOption("t")) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gov/nasa/pds/validate/ri/UserInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private boolean isLabel (String cliArg) {
private List<String> process (List<String> cliList){
List<String> lidvids = new ArrayList<String>();
for (String cliArg : cliList) {
if (cliArg.startsWith ("urn:nasa:pds:")) {
if (cliArg.startsWith ("urn:")) {
lidvids.add (cliArg);
} else if (this.isLabel (cliArg)) {
lidvids.add (this.labels_lidvid);
Expand Down

0 comments on commit d6b5ed4

Please sign in to comment.