mirror of
https://github.com/anthonyoteri/dredge.git
synced 2026-06-05 15:26:53 -04:00
Create initial project structure
The initial project structure includes the base scaffolding of the application as well as the ability to fetch the repo list from the remote endpoint.
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use clap::Args;
|
||||
use clap::Parser;
|
||||
use clap::Subcommand;
|
||||
use clap::ValueEnum;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "dredge", version, author)]
|
||||
#[command(about = "A Docker Registry CLI tool", long_about = None)]
|
||||
pub(crate) struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
|
||||
#[arg(short = 'c', long = "config")]
|
||||
pub config: Option<OsString>,
|
||||
|
||||
#[arg(
|
||||
long = "log-level",
|
||||
require_equals = true,
|
||||
value_name = "LEVEL",
|
||||
num_args = 0..=1,
|
||||
default_value_t = LogLevel::Info,
|
||||
default_missing_value="info",
|
||||
value_enum
|
||||
)]
|
||||
pub log_level: LogLevel,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum LogLevel {
|
||||
Trace,
|
||||
Debug,
|
||||
Info,
|
||||
Warn,
|
||||
Error,
|
||||
Off,
|
||||
}
|
||||
|
||||
impl From<LogLevel> for log::LevelFilter {
|
||||
fn from(lvl: LogLevel) -> Self {
|
||||
match lvl {
|
||||
LogLevel::Trace => Self::Trace,
|
||||
LogLevel::Debug => Self::Debug,
|
||||
LogLevel::Info => Self::Info,
|
||||
LogLevel::Warn => Self::Warn,
|
||||
LogLevel::Error => Self::Error,
|
||||
LogLevel::Off => Self::Off,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Commands {
|
||||
Repo(RepoArgs),
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct RepoArgs {
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: RepoCommands,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum RepoCommands {
|
||||
List,
|
||||
}
|
||||
Reference in New Issue
Block a user