mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Improve ListDomainsCommand to list domains on multiple TLDs
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140053423
This commit is contained in:
parent
35d88a9f8c
commit
5eb9702f05
11 changed files with 120 additions and 88 deletions
|
@ -14,20 +14,24 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.tools.server.ListDomainsAction;
|
||||
import java.util.List;
|
||||
|
||||
/** Command to list all second-level domains associated with a TLD. */
|
||||
@Parameters(separators = " =", commandDescription = "List domains associated with a TLD.")
|
||||
/** Command to list all second-level domains on specified TLD(s). */
|
||||
@Parameters(separators = " =", commandDescription = "List domains on TLD(s).")
|
||||
final class ListDomainsCommand extends ListObjectsCommand {
|
||||
|
||||
@Parameter(
|
||||
names = {"-t", "--tld"},
|
||||
description = "Top level domain whose second-level domains shall be listed.",
|
||||
names = {"-t", "--tld", "--tlds"},
|
||||
description = "Comma-delimited list of top-level domain(s) to list second-level domains of.",
|
||||
required = true)
|
||||
private String tld;
|
||||
private List<String> tlds;
|
||||
|
||||
@Override
|
||||
String getCommandPath() {
|
||||
|
@ -38,6 +42,8 @@ final class ListDomainsCommand extends ListObjectsCommand {
|
|||
* (in addition to the usual ones). */
|
||||
@Override
|
||||
ImmutableMap<String, Object> getParameterMap() {
|
||||
return ImmutableMap.<String, Object>of("tld", tld);
|
||||
String tldsParam = Joiner.on(',').join(tlds);
|
||||
checkArgument(tldsParam.length() < 1024, "Total length of TLDs is too long for URL parameter");
|
||||
return ImmutableMap.<String, Object>of("tlds", tldsParam);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue