tnn 0.1.3

A quality of life developer tool to interact with Telenor services
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::future::Future;

use crate::{core::api::calls, extension::ExtensionContext};
use anyhow::Result;
use clap::{CommandFactory, FromArgMatches};

pub async fn add_command<Command: CommandFactory + FromArgMatches + 'static, Output: Future<Output = Result<()>>>(
	ctx: &ExtensionContext,
	command: &'static impl Fn(Command) -> Output,
) -> Result<()> {
	ctx.call(
		&calls::WITH_CORE,
		calls::WithCore(Box::new(move |core| {
			core.add_command::<Command>(Box::new(move |args| Box::pin(async move { command(args).await })))
		})),
	)
	.await
}