Skip to content

Commit 625619f

Browse files
committed
Add primary command sample
- New spring-shell-sample-catalog which is a skeleton meant for future view overhaul work. - Relates #755
1 parent 6fd1a1c commit 625619f

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'org.springframework.shell.sample'
3+
id 'org.springframework.boot'
4+
id 'org.graalvm.buildtools.native'
5+
}
6+
7+
description = 'Spring Shell Sample Catalog'
8+
9+
dependencies {
10+
management platform(project(":spring-shell-management"))
11+
implementation project(':spring-shell-starters:spring-shell-starter-jna')
12+
testImplementation project(':spring-shell-starters:spring-shell-starter-test')
13+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
14+
testImplementation 'org.awaitility:awaitility'
15+
}
16+
17+
springBoot {
18+
buildInfo()
19+
}
20+
21+
if (project.hasProperty('springShellSampleE2E') && springShellSampleE2E.toBoolean()) {
22+
bootJar {
23+
archiveName = "$baseName.$extension"
24+
}
25+
}
26+
27+
graalvmNative {
28+
metadataRepository {
29+
enabled = true
30+
}
31+
binaries {
32+
main {
33+
if (project.hasProperty('springShellSampleMusl') && springShellSampleMusl.toBoolean()) {
34+
buildArgs.add('--static')
35+
buildArgs.add('--libc=musl')
36+
}
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.catalog;
17+
18+
import org.springframework.shell.command.annotation.Command;
19+
import org.springframework.shell.command.annotation.Option;
20+
21+
@Command
22+
public class CatalogCommand {
23+
24+
@Command
25+
String catalog(
26+
@Option() String arg
27+
) {
28+
return String.format("Hi arg=%s", arg);
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.catalog;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
import org.springframework.shell.command.annotation.CommandScan;
20+
21+
@Configuration
22+
@CommandScan
23+
class CatalogConfiguration {
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.catalog;
17+
18+
import org.springframework.boot.Banner.Mode;
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
22+
@SpringBootApplication
23+
public class SpringShellApplication {
24+
25+
public static void main(String[] args) throws Exception {
26+
SpringApplication application = new SpringApplication(SpringShellApplication.class);
27+
application.setBannerMode(Mode.OFF);
28+
application.run(args);
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
spring:
2+
main:
3+
banner-mode: off
4+
shell:
5+
noninteractive:
6+
primary-command: catalog
7+
## disable console logging
8+
logging:
9+
pattern:
10+
console:
11+
## log debug from a cli
12+
# file:
13+
# name: shell.log
14+
# level:
15+
# root: debug
16+
# org:
17+
# springframework:
18+
# shell: debug

0 commit comments

Comments
 (0)