Merge pull request #1196 from epage/dest

fix(serve): Don't offer unused `--destination`
This commit is contained in:
Ed Page 2024-07-05 13:51:40 -05:00 committed by GitHub
commit 629f2691a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 14 deletions

View file

@ -11,10 +11,6 @@ pub(crate) struct ConfigArgs {
#[arg(short, long, value_name = "FILE")]
config: Option<path::PathBuf>,
/// Site destination folder [default: ./_site]
#[arg(short, long, value_name = "DIR")]
destination: Option<path::PathBuf>,
/// Include drafts.
#[arg(long)]
drafts: bool,
@ -37,15 +33,6 @@ impl ConfigArgs {
cobalt_config::Config::from_cwd(".")?
};
config.abs_dest = self
.destination
.as_deref()
.map(|d| {
std::fs::create_dir_all(d)?;
dunce::canonicalize(d)
})
.transpose()?;
if let Some(drafts) = self.drafts() {
config.include_drafts = drafts;
}

View file

@ -7,13 +7,26 @@ use crate::error::Result;
/// Build the cobalt project at the source dir
#[derive(Clone, Debug, PartialEq, Eq, clap::Args)]
pub(crate) struct BuildArgs {
/// Site destination folder [default: ./_site]
#[arg(short, long, value_name = "DIR", help_heading = "Config")]
destination: Option<std::path::PathBuf>,
#[command(flatten, next_help_heading = "Config")]
pub(crate) config: args::ConfigArgs,
}
impl BuildArgs {
pub(crate) fn run(&self) -> Result<()> {
let config = self.config.load_config()?;
let mut config = self.config.load_config()?;
config.abs_dest = self
.destination
.as_deref()
.map(|d| {
fs::create_dir_all(d)?;
dunce::canonicalize(d)
})
.transpose()?;
let config = cobalt::cobalt_model::Config::from_config(config)?;
build(config)?;