mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-26 02:11:56 +00:00
feat: Add more helper
This commit is contained in:
@@ -396,7 +396,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<Params, InheritedParams> ParentHandler<Params, InheritedParams> {
|
impl<Params, InheritedParams> ParentHandler<Params, InheritedParams> {
|
||||||
pub fn subcommand<Context, H>(mut self, name: Option<&'static str>, handler: H) -> Self
|
pub fn subcommand<Context, H>(
|
||||||
|
mut self,
|
||||||
|
name: impl Into<Option<&'static str>>,
|
||||||
|
handler: H,
|
||||||
|
) -> Self
|
||||||
where
|
where
|
||||||
Context: IntoContext,
|
Context: IntoContext,
|
||||||
H: Handler<Context, InheritedParams = NoParams> + PrintCliResult<Context> + 'static,
|
H: Handler<Context, InheritedParams = NoParams> + PrintCliResult<Context> + 'static,
|
||||||
@@ -406,7 +410,7 @@ impl<Params, InheritedParams> ParentHandler<Params, InheritedParams> {
|
|||||||
{
|
{
|
||||||
self.subcommands.insert(
|
self.subcommands.insert(
|
||||||
handler.contexts(),
|
handler.contexts(),
|
||||||
name,
|
name.into(),
|
||||||
DynHandler::WithCli(Arc::new(AnyHandler {
|
DynHandler::WithCli(Arc::new(AnyHandler {
|
||||||
_ctx: PhantomData,
|
_ctx: PhantomData,
|
||||||
handler: WithCliBindings {
|
handler: WithCliBindings {
|
||||||
@@ -417,7 +421,11 @@ impl<Params, InheritedParams> ParentHandler<Params, InheritedParams> {
|
|||||||
);
|
);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn subcommand_no_cli<Context, H>(mut self, name: Option<&'static str>, handler: H) -> Self
|
pub fn subcommand_no_cli<Context, H>(
|
||||||
|
mut self,
|
||||||
|
name: impl Into<Option<&'static str>>,
|
||||||
|
handler: H,
|
||||||
|
) -> Self
|
||||||
where
|
where
|
||||||
Context: IntoContext,
|
Context: IntoContext,
|
||||||
H: Handler<Context, InheritedParams = NoParams> + 'static,
|
H: Handler<Context, InheritedParams = NoParams> + 'static,
|
||||||
@@ -427,7 +435,7 @@ impl<Params, InheritedParams> ParentHandler<Params, InheritedParams> {
|
|||||||
{
|
{
|
||||||
self.subcommands.insert(
|
self.subcommands.insert(
|
||||||
handler.contexts(),
|
handler.contexts(),
|
||||||
name,
|
name.into(),
|
||||||
DynHandler::WithoutCli(Arc::new(AnyHandler {
|
DynHandler::WithoutCli(Arc::new(AnyHandler {
|
||||||
_ctx: PhantomData,
|
_ctx: PhantomData,
|
||||||
handler,
|
handler,
|
||||||
@@ -443,7 +451,7 @@ where
|
|||||||
{
|
{
|
||||||
pub fn subcommand_with_inherited<Context, H, F>(
|
pub fn subcommand_with_inherited<Context, H, F>(
|
||||||
mut self,
|
mut self,
|
||||||
name: Option<&'static str>,
|
name: impl Into<Option<&'static str>>,
|
||||||
handler: H,
|
handler: H,
|
||||||
inherit: F,
|
inherit: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
@@ -457,7 +465,7 @@ where
|
|||||||
{
|
{
|
||||||
self.subcommands.insert(
|
self.subcommands.insert(
|
||||||
handler.contexts(),
|
handler.contexts(),
|
||||||
name,
|
name.into(),
|
||||||
DynHandler::WithCli(Arc::new(AnyHandler {
|
DynHandler::WithCli(Arc::new(AnyHandler {
|
||||||
_ctx: PhantomData,
|
_ctx: PhantomData,
|
||||||
handler: WithCliBindings {
|
handler: WithCliBindings {
|
||||||
@@ -474,7 +482,7 @@ where
|
|||||||
}
|
}
|
||||||
pub fn subcommand_with_inherited_no_cli<Context, H, F>(
|
pub fn subcommand_with_inherited_no_cli<Context, H, F>(
|
||||||
mut self,
|
mut self,
|
||||||
name: Option<&'static str>,
|
name: impl Into<Option<&'static str>>,
|
||||||
handler: H,
|
handler: H,
|
||||||
inherit: F,
|
inherit: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
@@ -488,7 +496,7 @@ where
|
|||||||
{
|
{
|
||||||
self.subcommands.insert(
|
self.subcommands.insert(
|
||||||
handler.contexts(),
|
handler.contexts(),
|
||||||
name,
|
name.into(),
|
||||||
DynHandler::WithoutCli(Arc::new(AnyHandler {
|
DynHandler::WithoutCli(Arc::new(AnyHandler {
|
||||||
_ctx: PhantomData,
|
_ctx: PhantomData,
|
||||||
handler: InheritanceHandler::<Context, Params, InheritedParams, H, F> {
|
handler: InheritanceHandler::<Context, Params, InheritedParams, H, F> {
|
||||||
|
|||||||
Reference in New Issue
Block a user