Initial upload with CI/CD workflow
This commit is contained in:
53
app/src/main.rs
Normal file
53
app/src/main.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
mod cli;
|
||||||
|
mod parser;
|
||||||
|
mod tui;
|
||||||
|
mod config;
|
||||||
|
mod generator;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use cli::{Cli, Commands};
|
||||||
|
use config::Config;
|
||||||
|
use tui::TuiApp;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
let cli = Cli::parse();
|
||||||
|
let config = Config::load_or_default()?;
|
||||||
|
|
||||||
|
match &cli.command {
|
||||||
|
Commands::Generate { command, output } => {
|
||||||
|
let parsed = parser::HelpParser::parse_command(command).await?;
|
||||||
|
if let Some(path) = output {
|
||||||
|
config::ConfigManager::export_config(&parsed, path)?;
|
||||||
|
}
|
||||||
|
println!("Successfully parsed command: {}", command);
|
||||||
|
}
|
||||||
|
Commands::Interactive { command } => {
|
||||||
|
let parsed = if let Some(cmd) = command {
|
||||||
|
parser::HelpParser::parse_command(cmd).await?
|
||||||
|
} else {
|
||||||
|
parser::HelpParser::parse_default_commands().await?
|
||||||
|
};
|
||||||
|
let mut app = TuiApp::new(parsed, config);
|
||||||
|
app.run().await?;
|
||||||
|
}
|
||||||
|
Commands::Export { command, output } => {
|
||||||
|
let parsed = parser::HelpParser::parse_command(command).await?;
|
||||||
|
config::ConfigManager::export_config(&parsed, output)?;
|
||||||
|
}
|
||||||
|
Commands::List => {
|
||||||
|
let commands = config::ConfigManager::list_saved_configs()?;
|
||||||
|
for cmd in commands {
|
||||||
|
println!("- {}", cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Commands::Run { name } => {
|
||||||
|
if let Some(parsed) = config::ConfigManager::load_config(name)? {
|
||||||
|
let mut app = TuiApp::new(parsed, config);
|
||||||
|
app.run().await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user