tnn 0.1.3

A quality of life developer tool to interact with Telenor services
Documentation
use crate::util::parent_command::{CommandHandlerReturnType, ParentCommand};
use anyhow::Result;
use clap::{CommandFactory, FromArgMatches};

pub struct Core {
	command: ParentCommand,
}

impl<'a> Core {
	pub fn new(command: ParentCommand) -> Self {
		Self { command }
	}

	pub fn add_command<Command: CommandFactory + FromArgMatches + 'static>(
		mut self,
		handler: Box<dyn Fn(Command) -> CommandHandlerReturnType>,
	) -> Result<Self> {
		self.command = self.command.add_command::<Command>(handler)?;
		Ok(self)
	}

	pub fn finish(self) -> ParentCommand {
		self.command
	}
}