diff --git a/smithy-cli/src/it/java/software/amazon/smithy/cli/InitCommandTest.java b/smithy-cli/src/it/java/software/amazon/smithy/cli/InitCommandTest.java index 81fd5dfab09..46252aca092 100644 --- a/smithy-cli/src/it/java/software/amazon/smithy/cli/InitCommandTest.java +++ b/smithy-cli/src/it/java/software/amazon/smithy/cli/InitCommandTest.java @@ -34,23 +34,30 @@ public void init() { } @Test - public void missingTemplate() { + public void usesDefaultTemplate() { IntegUtils.withProject(PROJECT_NAME, templatesDir -> { setupTemplatesDirectory(templatesDir); - IntegUtils.withTempDir("missingTemplate", dir -> { + IntegUtils.withTempDir("defaultTemplate", dir -> { RunResult result = IntegUtils.run( - dir, ListUtils.of("init", "-u", templatesDir.toString())); + dir, ListUtils.of("init", "-u", templatesDir.toString())); assertThat(result.getOutput(), - containsString("Please specify a template using `--template` or `-t`")); - assertThat(result.getExitCode(), is(1)); + containsString("Smithy project created in directory: quickstart-cli")); + assertThat(result.getExitCode(), is(0)); }); + }); + } + + @Test + public void missingTemplate() { + IntegUtils.withProject(PROJECT_NAME, templatesDir -> { + setupTemplatesDirectory(templatesDir); IntegUtils.withTempDir("emptyTemplateName", dir -> { RunResult result = IntegUtils.run( dir, ListUtils.of("init", "-t", "", "-u", templatesDir.toString())); assertThat(result.getOutput(), - containsString("Please specify a template using `--template` or `-t`")); + containsString("Please specify a template name using `--template` or `-t`")); assertThat(result.getExitCode(), is(1)); }); }); diff --git a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java index ac7b67fe005..2a78b21bbde 100644 --- a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java +++ b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/InitCommand.java @@ -44,7 +44,7 @@ final class InitCommand implements Command { private static final String SMITHY_TEMPLATE_JSON = "smithy-templates.json"; private static final String DEFAULT_REPOSITORY_URL = "https://github.com/smithy-lang/smithy-examples.git"; - + private static final String DEFAULT_TEMPLATE_NAME = "quickstart-cli"; private static final String DOCUMENTATION = "documentation"; private static final String NAME = "name"; @@ -157,7 +157,7 @@ private void cloneTemplate(Path temp, ObjectNode smithyTemplatesNode, String tem throws IOException, InterruptedException, URISyntaxException { if (template == null || template.isEmpty()) { - throw new IllegalArgumentException("Please specify a template using `--template` or `-t`"); + throw new IllegalArgumentException("Please specify a template name using `--template` or `-t`"); } ObjectNode templatesNode = getTemplatesNode(smithyTemplatesNode); @@ -275,7 +275,7 @@ private static String pad(String s, int n) { } private static final class Options implements ArgumentReceiver { - private String template; + private String template = DEFAULT_TEMPLATE_NAME; private String directory; private Boolean listTemplates = false; private String repositoryUrl = DEFAULT_REPOSITORY_URL;