Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.47 KB

appendices-technical-intro-commandcatalog.adoc

File metadata and controls

43 lines (36 loc) · 1.47 KB

Command Catalog

The CommandCatalog interface defines how command registrations exist in a shell application. It is possible to dynamically register and de-register commands, which gives flexibility for use cases where possible commands come and go, depending on a shell’s state. Consider the following example:

link:{snippets}/CommandCatalogSnippets.java[role=include]

Command Resolver

You can implement the CommandResolver interface and define a bean to dynamically resolve mappings from a command’s name to its CommandRegistration instances. Consider the following example:

link:{snippets}/CommandCatalogSnippets.java[role=include]
Important
A current limitation of a CommandResolver is that it is used every time commands are resolved. Thus, we advise not using it if a command resolution call takes a long time, as it would make the shell feel sluggish.

Command Catalog Customizer

You can use the CommandCatalogCustomizer interface to customize a CommandCatalog. Its main use is to modify a catalog. Also, within spring-shell auto-configuration, this interface is used to register existing CommandRegistration beans into a catalog. Consider the following example:

link:{snippets}/CommandCatalogSnippets.java[role=include]

You can create a CommandCatalogCustomizer as a bean, and Spring Shell handles the rest.