This repository was archived by the owner on May 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
spring-cloud-dataflow-shell-core/src/main/java/org/springframework/cloud/dataflow/shell/config Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1616
1717package org .springframework .cloud .dataflow .shell .config ;
1818
19+ import org .jline .terminal .Terminal ;
20+
1921import org .springframework .boot .ApplicationRunner ;
2022import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
2123import org .springframework .boot .context .properties .EnableConfigurationProperties ;
@@ -56,6 +58,11 @@ public RestTemplate restTemplate() {
5658 return DataFlowTemplate .getDefaultDataflowRestTemplate ();
5759 }
5860
61+ @ Bean
62+ public TablesResultHandler tablesResultHandler (Terminal terminal ) {
63+ return new TablesResultHandler (terminal );
64+ }
65+
5966 @ Configuration (proxyBeanMethods = false )
6067 static class ShellRunnerConfiguration {
6168
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2022 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 .cloud .dataflow .shell .config ;
17+
18+ import java .util .List ;
19+
20+ import org .jline .terminal .Terminal ;
21+
22+ import org .springframework .shell .result .TerminalAwareResultHandler ;
23+ import org .springframework .shell .table .Table ;
24+
25+ /**
26+ * Result handler which output's multiple tables.
27+ *
28+ * @author Janne Valkealahti
29+ */
30+ public class TablesResultHandler extends TerminalAwareResultHandler <List <Table >> {
31+
32+ public TablesResultHandler (Terminal terminal ) {
33+ super (terminal );
34+ }
35+
36+ @ Override
37+ protected void doHandleResult (List <Table > tables ) {
38+ for (Table table : tables ) {
39+ terminal .writer ().println (table .render (terminal .getWidth ()));
40+ }
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments