Use -t instead of main params for TLDs in nomulus count_domains command (#493)

* Use -t instead of main params for TLDs in nomulus count_domains command

This makes the command consistent with list_domains. I use both frequently and it
was annoying forgetting which one takes -t and which uses main parameters. Now
they both work the same way.
This commit is contained in:
Ben McIlwain 2020-02-20 16:23:38 -05:00 committed by GitHub
parent 05ed4fd849
commit ec6157b6ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -30,15 +30,18 @@ import org.joda.time.DateTime;
@Parameters(separators = " =", commandDescription = "Show count of domains on TLD") @Parameters(separators = " =", commandDescription = "Show count of domains on TLD")
final class CountDomainsCommand implements CommandWithRemoteApi { final class CountDomainsCommand implements CommandWithRemoteApi {
@Parameter(description = "TLD(s) to count domains on", required = true) @Parameter(
private List<String> mainParameters; names = {"-t", "--tld", "--tlds"},
description = "Comma-delimited list of TLD(s) to count domains on",
required = true)
private List<String> tlds;
@Inject Clock clock; @Inject Clock clock;
@Override @Override
public void run() { public void run() {
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
assertTldsExist(mainParameters) assertTldsExist(tlds)
.forEach(tld -> System.out.printf("%s,%d\n", tld, getCountForTld(tld, now))); .forEach(tld -> System.out.printf("%s,%d\n", tld, getCountForTld(tld, now)));
} }

View file

@ -49,7 +49,7 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
persistActiveDomain(String.format("test-%d.baz", i)); persistActiveDomain(String.format("test-%d.baz", i));
} }
} }
runCommand("foo"); runCommand("-t=foo");
assertStdoutIs("foo,51\n"); assertStdoutIs("foo,51\n");
} }
@ -64,7 +64,7 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
persistDeletedDomain(String.format("del-%d.foo", j), clock.nowUtc().minusYears(1)); persistDeletedDomain(String.format("del-%d.foo", j), clock.nowUtc().minusYears(1));
} }
persistActiveDomain("not-counted.qux"); persistActiveDomain("not-counted.qux");
runCommand("foo", "bar", "baz"); runCommand("--tlds=foo,bar,baz");
assertStdoutIs("foo,29\nbar,0\nbaz,17\n"); assertStdoutIs("foo,29\nbar,0\nbaz,17\n");
} }
} }