diff --git a/spring-shell-samples/spring-shell-sample-catalog/spring-shell-sample-catalog.gradle b/spring-shell-samples/spring-shell-sample-catalog/spring-shell-sample-catalog.gradle new file mode 100644 index 00000000..176d1d9a --- /dev/null +++ b/spring-shell-samples/spring-shell-sample-catalog/spring-shell-sample-catalog.gradle @@ -0,0 +1,39 @@ +plugins { + id 'org.springframework.shell.sample' + id 'org.springframework.boot' + id 'org.graalvm.buildtools.native' +} + +description = 'Spring Shell Sample Catalog' + +dependencies { + management platform(project(":spring-shell-management")) + implementation project(':spring-shell-starters:spring-shell-starter-jna') + testImplementation project(':spring-shell-starters:spring-shell-starter-test') + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.awaitility:awaitility' +} + +springBoot { + buildInfo() +} + +if (project.hasProperty('springShellSampleE2E') && springShellSampleE2E.toBoolean()) { + bootJar { + archiveName = "$baseName.$extension" + } +} + +graalvmNative { + metadataRepository { + enabled = true + } + binaries { + main { + if (project.hasProperty('springShellSampleMusl') && springShellSampleMusl.toBoolean()) { + buildArgs.add('--static') + buildArgs.add('--libc=musl') + } + } + } +} diff --git a/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogCommand.java b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogCommand.java new file mode 100644 index 00000000..641bc9de --- /dev/null +++ b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogCommand.java @@ -0,0 +1,30 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.shell.samples.catalog; + +import org.springframework.shell.command.annotation.Command; +import org.springframework.shell.command.annotation.Option; + +@Command +public class CatalogCommand { + + @Command + String catalog( + @Option() String arg + ) { + return String.format("Hi arg=%s", arg); + } +} diff --git a/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogConfiguration.java b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogConfiguration.java new file mode 100644 index 00000000..0fe93d75 --- /dev/null +++ b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/CatalogConfiguration.java @@ -0,0 +1,24 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.shell.samples.catalog; + +import org.springframework.context.annotation.Configuration; +import org.springframework.shell.command.annotation.CommandScan; + +@Configuration +@CommandScan +class CatalogConfiguration { +} diff --git a/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/SpringShellApplication.java b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/SpringShellApplication.java new file mode 100644 index 00000000..34d58e26 --- /dev/null +++ b/spring-shell-samples/spring-shell-sample-catalog/src/main/java/org/springframework/shell/samples/catalog/SpringShellApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.shell.samples.catalog; + +import org.springframework.boot.Banner.Mode; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringShellApplication { + + public static void main(String[] args) throws Exception { + SpringApplication application = new SpringApplication(SpringShellApplication.class); + application.setBannerMode(Mode.OFF); + application.run(args); + } + +} diff --git a/spring-shell-samples/spring-shell-sample-catalog/src/main/resources/application.yml b/spring-shell-samples/spring-shell-sample-catalog/src/main/resources/application.yml new file mode 100644 index 00000000..45c73b6f --- /dev/null +++ b/spring-shell-samples/spring-shell-sample-catalog/src/main/resources/application.yml @@ -0,0 +1,18 @@ +spring: + main: + banner-mode: off + shell: + noninteractive: + primary-command: catalog +## disable console logging +logging: + pattern: + console: +## log debug from a cli +# file: +# name: shell.log +# level: +# root: debug +# org: +# springframework: +# shell: debug