Basic zsh completion support
- This adds basic zsh support similarly to existing bash completion - New command "completion zsh" - Fix internal recursive command completion model for cases with deep nested commands - Fixes #927
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
* Copyright 2022-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.
|
||||
@@ -20,6 +20,7 @@ import org.springframework.shell.standard.AbstractShellComponent;
|
||||
import org.springframework.shell.standard.ShellComponent;
|
||||
import org.springframework.shell.standard.ShellMethod;
|
||||
import org.springframework.shell.standard.completion.BashCompletions;
|
||||
import org.springframework.shell.standard.completion.ZshCompletions;
|
||||
|
||||
/**
|
||||
* Command to create a shell completion files, i.e. for {@code bash}.
|
||||
@@ -52,4 +53,10 @@ public class Completion extends AbstractShellComponent {
|
||||
BashCompletions bashCompletions = new BashCompletions(resourceLoader, getCommandCatalog());
|
||||
return bashCompletions.generate(rootCommand);
|
||||
}
|
||||
|
||||
@ShellMethod(key = "completion zsh", value = "Generate zsh completion script")
|
||||
public String zsh() {
|
||||
ZshCompletions zshCompletions = new ZshCompletions(resourceLoader, getCommandCatalog());
|
||||
return zshCompletions.generate(rootCommand);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user