Skip to content

Commit

Permalink
add CLI option
Browse files Browse the repository at this point in the history
Added the option to set the archive tested. Tested with certified and it worked. Also tested with fred and it failed as not legal.
  • Loading branch information
Al Niessner authored and Al Niessner committed Aug 2, 2024
1 parent 076ba00 commit 9c39628
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/main/java/gov/nasa/pds/harvest/HarvestCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gov.nasa.pds.harvest.cmd.HarvestCmd;
import gov.nasa.pds.harvest.util.log.Log4jConfigurator;
import gov.nasa.pds.registry.common.meta.Metadata;
import gov.nasa.pds.registry.common.util.ArchiveStatus;
import gov.nasa.pds.registry.common.util.ExceptionUtils;
import gov.nasa.pds.registry.common.util.ManifestUtils;

Expand Down Expand Up @@ -108,11 +109,15 @@ public static void printHelp()
System.out.println(" -V, --version Print Harvest version");
System.out.println();
System.out.println("Optional parameters:");
System.out.println(" -o <dir> Output directory (applies to supplemental products only).");
System.out.println(" Default is /tmp/harvest/out");
System.out.println(" -l <file> Log file. Default is /tmp/harvest/harvest.log");
System.out.println(" -v <level> Logger verbosity: DEBUG, INFO (default), WARNING, ERROR");
System.out.println(" -O, --overwrite Overwrite registered products");
System.out.println(" -o <dir> Output directory (applies to supplemental products only).");
System.out.println(" Default is /tmp/harvest/out");
System.out.println(" -l <file> Log file. Default is /tmp/harvest/harvest.log");
System.out.println(" -v <level> Logger verbosity: DEBUG, INFO (default), WARNING, ERROR");
System.out.println(" -O, --overwrite Overwrite registered products");
System.out.println(" -a, --archive-status Set the archive status for all products defaulting to staged");
for (String name : new ArchiveStatus().statusNames) {
System.out.println(" " + name);
}
}


Expand Down Expand Up @@ -199,6 +204,9 @@ private void initOptions()

bld = Option.builder("O").longOpt("overwrite");
options.addOption(bld.build());

bld = Option.builder("a").longOpt("archive-status").hasArg().argName("archive_status");
options.addOption(bld.build());
}

}
7 changes: 6 additions & 1 deletion src/main/java/gov/nasa/pds/harvest/cmd/HarvestCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import gov.nasa.pds.harvest.util.log.LogUtils;
import gov.nasa.pds.harvest.util.out.WriterManager;
import gov.nasa.pds.registry.common.meta.BasicMetadataExtractor;
import gov.nasa.pds.registry.common.util.ArchiveStatus;


/**
Expand Down Expand Up @@ -58,6 +59,10 @@ public HarvestCmd()
@Override
public void run(CommandLine cmdLine) throws Exception
{
if (cmdLine.hasOption("archive-status")) {
this.archive_status = cmdLine.getOptionValue("archive-status").toLowerCase();
new ArchiveStatus().validateStatusName(archive_status);;
}
configure(cmdLine);

try
Expand Down Expand Up @@ -151,7 +156,7 @@ private void configure(CommandLine cmdLine) throws Exception
// Xpath maps
XPathCacheLoader xpcLoader = new XPathCacheLoader();
xpcLoader.load(cfg.getXpathMaps());

// Processors
if(cfg.getLoad().getDirectories() != null || cfg.getLoad().getFiles() != null)
{
Expand Down

0 comments on commit 9c39628

Please sign in to comment.