Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit da0b49e

Browse files
committed
Override default picocli help renderer
1 parent ebec93b commit da0b49e

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spring Boot Spigot Starter
22

33
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Alan-Gomes/mcspring-boot/fork)
4-
[![Maven Central](https://img.shields.io/maven-central/v/dev.alangomes/spigot-spring-boot-starter.svg)](https://search.maven.org/#artifactdetails%7Cdev.alangomes%7Cspigot-spring-boot-starter%7C0.11.0%7Cjar)
4+
[![Maven Central](https://img.shields.io/maven-central/v/dev.alangomes/spigot-spring-boot-starter.svg)](https://search.maven.org/#artifactdetails%7Cdev.alangomes%7Cspigot-spring-boot-starter%7C0.11.1%7Cjar)
55
[![License](https://img.shields.io/github/license/Alan-Gomes/mcspring-boot.svg?style=popout)](https://github.com/Alan-Gomes/mcspring-boot/blob/master/LICENSE)
66
[![Coverage Status](https://img.shields.io/coveralls/github/Alan-Gomes/mcspring-boot/master.svg)](https://coveralls.io/github/Alan-Gomes/mcspring-boot?branch=master)
77
[![GitHub Issues](https://img.shields.io/github/issues/Alan-Gomes/mcspring-boot.svg)](https://github.com/Alan-Gomes/mcspring-boot/issues)
@@ -29,7 +29,7 @@ Add the Spring boot starter to your project
2929
<dependency>
3030
<groupId>dev.alangomes</groupId>
3131
<artifactId>spigot-spring-boot-starter</artifactId>
32-
<version>0.11.0</version>
32+
<version>0.11.1</version>
3333
</dependency>
3434
```
3535

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>dev.alangomes</groupId>
1010
<artifactId>spigot-spring-boot-starter</artifactId>
1111
<packaging>jar</packaging>
12-
<version>0.11.0</version>
12+
<version>0.11.1</version>
1313
<description>Spring support for spigot plugins</description>
1414
<url>https://github.com/Alan-Gomes/mcspring-boot</url>
1515

src/main/java/dev/alangomes/springspigot/picocli/CommandLineDefinition.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
import org.springframework.aop.support.AopUtils;
77
import org.springframework.beans.factory.BeanFactory;
88
import picocli.CommandLine;
9+
import picocli.CommandLine.IHelpSectionRenderer;
910

1011
import java.util.Collections;
1112
import java.util.HashMap;
13+
import java.util.Map;
1214
import java.util.Set;
15+
import java.util.function.Function;
16+
import java.util.stream.Collectors;
1317

1418
@Getter
1519
public class CommandLineDefinition {
@@ -42,6 +46,8 @@ public CommandLine build(BeanFactory factory) {
4246
commandLine.addSubcommand(key, value);
4347
}
4448
});
49+
50+
overrideHelpRenderers(commandLine);
4551
return commandLine;
4652
}
4753

@@ -58,4 +64,16 @@ public Set<String> getCommandNames() {
5864
return Collections.unmodifiableSet(subcommands.keySet());
5965
}
6066

67+
private void overrideHelpRenderers(CommandLine commandLine) {
68+
Map<String, IHelpSectionRenderer> renderers = commandLine.getHelpSectionMap().keySet()
69+
.stream()
70+
.collect(Collectors.toMap(Function.identity(), (k) -> overrideRenderer(commandLine.getHelpSectionMap().get(k))));
71+
commandLine.setHelpSectionMap(renderers);
72+
}
73+
74+
private IHelpSectionRenderer overrideRenderer(IHelpSectionRenderer renderer) {
75+
// strip carriage returns when running inside a windows server
76+
return (h) -> renderer.render(h).replaceAll("\\r", "");
77+
}
78+
6179
}

0 commit comments

Comments
 (0)