feat: refactor frontend configuration

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-01 02:31:44 +02:00
parent e235483783
commit 8cd68d569b
22 changed files with 557 additions and 268 deletions

View File

@@ -0,0 +1,71 @@
use std::path::PathBuf;
use clap::Args;
use crate::stage0_config::{
PleaseConfigBuilder, PleaseProjectConfigBuilder, PleaseSettingsConfigBuilder,
};
#[derive(Args, Debug, Clone)]
pub struct ConfigArgs {
/// Which repository to publish against. If not supplied remote url will be inferred from environment or fail if not present.
#[arg(
env = "CUDDLE_PLEASE_API_URL",
long,
global = true,
help_heading = "Config"
)]
pub api_url: Option<String>,
/// repo is the name of repository you want to release for
#[arg(
env = "CUDDLE_PLEASE_REPO",
long,
global = true,
help_heading = "Config"
)]
pub repo: Option<String>,
/// owner is the name of user from which the repository belongs <user>/<repo>
#[arg(
env = "CUDDLE_PLEASE_OWNER",
long,
global = true,
help_heading = "Config"
)]
pub owner: Option<String>,
/// which source directory to use, if not set `std::env::current_dir` is used instead.
#[arg(
env = "CUDDLE_PLEASE_SOURCE",
long,
global = true,
help_heading = "Config"
)]
pub source: Option<PathBuf>,
/// which branch is being run from
#[arg(
env = "CUDDLE_PLEASE_BRANCH",
long,
global = true,
help_heading = "Config"
)]
pub branch: Option<String>,
}
impl From<ConfigArgs> for PleaseConfigBuilder {
fn from(value: ConfigArgs) -> Self {
Self {
project: Some(PleaseProjectConfigBuilder {
owner: value.owner,
repository: value.repo,
source: value.source,
branch: value.branch,
}),
settings: Some(PleaseSettingsConfigBuilder {
api_url: value.api_url,
}),
}
}
}