use std::{ffi::OsString, path::PathBuf};
use clap::{Args, Parser, Subcommand, ValueEnum};
#[derive(Debug, Clone, Parser)]
#[command(version, about)]
pub struct Envoluntary {
#[command(subcommand)]
pub command: EnvoluntaryCommands,
}
#[derive(Debug, Clone, Subcommand)]
pub enum EnvoluntaryCommands {
Config {
#[command(subcommand)]
config: EnvoluntaryConfigCommands,
},
Shell {
#[command(subcommand)]
shell: EnvoluntaryShellCommands,
},
}
#[derive(Debug, Clone, Subcommand)]
pub enum EnvoluntaryConfigCommands {
PrintPath,
Edit(EnvoluntaryConfigEditArgs),
AddEntry(EnvoluntaryConfigAddEntryArgs),
PrintMatchingEntries(EnvoluntaryConfigPrintMatchingEntriesArgs),
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryConfigEditArgs {
#[arg(long, env = "ENVOLUNTARY_CONFIG_PATH")]
pub config_path: Option<PathBuf>,
#[arg(long, env = "EDITOR")]
pub editor_program: Option<OsString>,
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryConfigAddEntryArgs {
pub pattern: String,
pub flake_reference: String,
#[arg(long)]
pub pattern_adjacent: Option<String>,
#[arg(long)]
pub impure: Option<bool>,
#[arg(long, env = "ENVOLUNTARY_CONFIG_PATH")]
pub config_path: Option<PathBuf>,
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryConfigPrintMatchingEntriesArgs {
pub path: PathBuf,
#[arg(long, env = "ENVOLUNTARY_CONFIG_PATH")]
pub config_path: Option<PathBuf>,
}
#[derive(Debug, Clone, Subcommand)]
pub enum EnvoluntaryShellCommands {
CheckNixVersion,
Hook(EnvoluntaryShellHookArgs),
Export(EnvoluntaryShellExportArgs),
PrintCachePath(EnvoluntaryShellPrintCachePathArgs),
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryShellHookArgs {
pub shell: EnvoluntaryShell,
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryShellExportArgs {
pub shell: EnvoluntaryShell,
#[arg(long, env = "ENVOLUNTARY_CONFIG_PATH")]
pub config_path: Option<PathBuf>,
#[arg(long, env = "ENVOLUNTARY_CACHE_DIR")]
pub cache_dir: Option<PathBuf>,
#[arg(long)]
pub flake_references: Option<Vec<String>>,
pub impure: Option<bool>,
#[arg(long)]
pub force_update: bool,
#[arg(long)]
pub current_dir: Option<PathBuf>,
}
#[derive(Debug, Clone, Args)]
pub struct EnvoluntaryShellPrintCachePathArgs {
#[arg(long)]
pub flake_reference: String,
#[arg(long, env = "ENVOLUNTARY_CACHE_DIR")]
pub cache_dir: Option<PathBuf>,
}
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum EnvoluntaryShell {
Bash,
Fish,
Json,
Zsh,
}