mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Align parameter formats for zone data commands
Seems silly that one command uses --tlds for the required parameter, while the other one doesn't. As part of this change, create a DateParameter for commands that require only a date (i.e. a DateTime parameter restricted to midnight UTC). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148106721
This commit is contained in:
parent
0417f3d3a1
commit
b3b4bba9aa
3 changed files with 153 additions and 7 deletions
|
@ -21,7 +21,7 @@ import static org.joda.time.Duration.standardMinutes;
|
|||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.tools.params.DateTimeParameter;
|
||||
import google.registry.tools.params.DateParameter;
|
||||
import google.registry.tools.server.GenerateZoneFilesAction;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -33,16 +33,17 @@ import org.joda.time.DateTime;
|
|||
final class GenerateZoneFilesCommand implements ServerSideCommand {
|
||||
|
||||
@Parameter(
|
||||
description = "A comma-separated list of TLDs to generate zone files for",
|
||||
description = "One or more TLDs to generate zone files for",
|
||||
required = true)
|
||||
private List<String> mainParameters;
|
||||
|
||||
// Default to latest midnight that's at least 2 minutes ago.
|
||||
@Parameter(
|
||||
names = "--export_time",
|
||||
description = "The (midnight UTC) time to generate the file for (defaults to last midnight).",
|
||||
validateWith = DateTimeParameter.class)
|
||||
private DateTime exportTime = DateTime.now(UTC).minus(standardMinutes(2)).withTimeAtStartOfDay();
|
||||
names = "--export_date",
|
||||
description = "The date to generate the file for (defaults to today, or yesterday if run "
|
||||
+ "before 00:02).",
|
||||
validateWith = DateParameter.class)
|
||||
private DateTime exportDate = DateTime.now(UTC).minus(standardMinutes(2)).withTimeAtStartOfDay();
|
||||
|
||||
private Connection connection;
|
||||
|
||||
|
@ -58,7 +59,7 @@ final class GenerateZoneFilesCommand implements ServerSideCommand {
|
|||
}
|
||||
ImmutableMap<String, Object> params = ImmutableMap.of(
|
||||
"tlds", mainParameters,
|
||||
"exportTime", exportTime.toString());
|
||||
"exportTime", exportDate.toString());
|
||||
Map<String, Object> response = connection.sendJson(GenerateZoneFilesAction.PATH, params);
|
||||
System.out.printf(
|
||||
"Job started at %s%s\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue