Add primary command sample

- New spring-shell-sample-catalog which is a skeleton meant for
  future view overhaul work.
- Relates #755
This commit is contained in:
Janne Valkealahti
2023-07-05 10:35:30 +01:00
parent 6fd1a1c78a
commit 625619fc92
5 changed files with 142 additions and 0 deletions

View File

@@ -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')
}
}
}
}

View File

@@ -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);
}
}

View File

@@ -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 {
}

View File

@@ -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);
}
}

View File

@@ -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