Command Not Found
在默认情况下,缺失的命令由 CommandNotFoundResultHandler
处理,并输出一条简单消息:
shell:>missing
No command found for 'missing'
在内部,CommandNotFoundResultHandler
使用 CommandNotFoundMessageProvider
,它是一个简单函数,可以将 ProviderContext
作为输入,并返回一条文本消息。以下是自定义消息提供程序可能的样子之一。
Unresolved include directive in modules/ROOT/pages/customization/commandnotfound.adoc - include::../../test/java/org/springframework/shell/docs/CommandNotFoundSnippets.java[]
可以通过将其定义为一个 bean 来更改此实现。
Unresolved include directive in modules/ROOT/pages/customization/commandnotfound.adoc - include::../../test/java/org/springframework/shell/docs/CommandNotFoundSnippets.java[]
CommandNotFoundResultHandler
是一个函数式接口,因此它可以作为 lambda 来编写。
Unresolved include directive in modules/ROOT/pages/customization/commandnotfound.adoc - include::../../test/java/org/springframework/shell/docs/CommandNotFoundSnippets.java[]