added argument parsing and structure with clap
This commit is contained in:
10
src/app/args/mod.rs
Normal file
10
src/app/args/mod.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use clap::Parser;
|
||||
|
||||
use self::structure::Args;
|
||||
|
||||
mod structure;
|
||||
|
||||
pub fn args() -> Args {
|
||||
return Args::parse();
|
||||
|
||||
}
|
||||
12
src/app/args/structure.rs
Normal file
12
src/app/args/structure.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Args {
|
||||
#[command(subcommand)]
|
||||
command: Option<CommandArg>
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum CommandArg {
|
||||
Build,
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
mod commands;
|
||||
pub mod builder;
|
||||
pub mod fs_util;
|
||||
mod args;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
@@ -8,6 +9,8 @@ use std::env;
|
||||
use commands::traits::Command;
|
||||
use commands::CommandRegistry;
|
||||
|
||||
use self::args::args;
|
||||
|
||||
pub struct App {
|
||||
command_regisrty: CommandRegistry,
|
||||
}
|
||||
@@ -19,9 +22,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(self, args: Vec<String>) {
|
||||
pub fn start(self, old_args: Vec<String>) {
|
||||
let args = args();
|
||||
Self::preapare_env_path();
|
||||
let command_args = &args[1..];
|
||||
let command_args = &old_args[1..];
|
||||
let mut path = String::from("");
|
||||
let mut argument_map = HashMap::new();
|
||||
let mut only_options_left = false;
|
||||
|
||||
Reference in New Issue
Block a user