use clap::{Parser, Subcommand};
use std::path::PathBuf;
use crate::commands::Commands;
#[derive(Parser)]
#[command(name = "nargo")]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
impl Cli {
pub fn parse() -> Self {
Parser::parse()
}
pub fn parse_from<I, T>(args: I) -> Self
where
I: IntoIterator<Item = T>,
T: Into<std::ffi::OsString> + Clone,
{
Parser::parse_from(args)
}
pub fn try_parse() -> Result<Self, clap::Error> {
Parser::try_parse()
}
pub fn execute(&self) -> color_eyre::eyre::Result<()> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(self.execute_async())
}
pub async fn execute_async(&self) -> color_eyre::eyre::Result<()> {
self.command.execute().await
}
}