Compare commits
1 Commits
v0.0.5
...
f9fd3cc558
Author | SHA1 | Date | |
---|---|---|---|
|
f9fd3cc558 |
@@ -6,11 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.0.5] - 2025-07-26
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- actually copy files
|
|
||||||
|
|
||||||
## [0.0.4] - 2025-07-26
|
## [0.0.4] - 2025-07-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.0.5"
|
version = "0.0.4"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
noil = { path = "crates/noil" }
|
noil = { path = "crates/noil" }
|
||||||
|
@@ -6,10 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(clap::Parser)]
|
#[derive(clap::Parser)]
|
||||||
pub struct ApplyCommand {
|
pub struct ApplyCommand {}
|
||||||
#[arg(long = "commit")]
|
|
||||||
commit: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ApplyCommand {
|
impl ApplyCommand {
|
||||||
pub async fn execute(&self) -> anyhow::Result<()> {
|
pub async fn execute(&self) -> anyhow::Result<()> {
|
||||||
@@ -20,15 +17,11 @@ impl ApplyCommand {
|
|||||||
|
|
||||||
let input = String::from_utf8_lossy(&buffer);
|
let input = String::from_utf8_lossy(&buffer);
|
||||||
|
|
||||||
if !self.commit {
|
let action = print_changes(&input).await?;
|
||||||
let action = print_changes(&input, !self.commit).await?;
|
match action {
|
||||||
match action {
|
Action::Quit => Ok(()),
|
||||||
Action::Quit => Ok(()),
|
Action::Apply { original } => apply(&original).await,
|
||||||
Action::Apply { original } => apply(&original).await,
|
Action::Edit => todo!(),
|
||||||
Action::Edit => todo!(),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
apply(&input).await
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,6 @@ use crate::{
|
|||||||
parse,
|
parse,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PREVIEW: bool = false;
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub struct EditCommand {
|
pub struct EditCommand {
|
||||||
#[arg()]
|
#[arg()]
|
||||||
@@ -70,7 +68,7 @@ impl EditCommand {
|
|||||||
.await
|
.await
|
||||||
.context("read noil file")?;
|
.context("read noil file")?;
|
||||||
|
|
||||||
let res = print_changes(&noil_content, PREVIEW).await;
|
let res = print_changes(&noil_content).await;
|
||||||
|
|
||||||
let action = match res {
|
let action = match res {
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
@@ -177,7 +175,6 @@ pub async fn apply(input: &str) -> anyhow::Result<()> {
|
|||||||
if existing.path.is_dir() {
|
if existing.path.is_dir() {
|
||||||
tracing::debug!("copying dir");
|
tracing::debug!("copying dir");
|
||||||
copy(&existing.path, path).await?;
|
copy(&existing.path, path).await?;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::fs::copy(&existing.path, &path)
|
tokio::fs::copy(&existing.path, &path)
|
||||||
@@ -238,9 +235,6 @@ async fn copy(source: &Path, dest: &Path) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
for entry in walkdir::WalkDir::new(source) {
|
for entry in walkdir::WalkDir::new(source) {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
|
||||||
tracing::debug!("copying path: {}", entry.path().display());
|
|
||||||
|
|
||||||
paths.push(entry.path().strip_prefix(source)?.to_path_buf());
|
paths.push(entry.path().strip_prefix(source)?.to_path_buf());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,12 +260,10 @@ async fn copy_path(src: &Path, dest: &Path) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if src.is_dir() {
|
if src.is_dir() {
|
||||||
tracing::info!("copying dir: {}", dest.display());
|
|
||||||
tokio::fs::create_dir_all(&dest).await.context("copy dir")?;
|
tokio::fs::create_dir_all(&dest).await.context("copy dir")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if src.is_file() {
|
if dest.is_file() {
|
||||||
tracing::info!("copying file: {}", dest.display());
|
|
||||||
tokio::fs::copy(&src, &dest).await.context("copy file")?;
|
tokio::fs::copy(&src, &dest).await.context("copy file")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ pub enum Action {
|
|||||||
Edit,
|
Edit,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn print_changes(input: &str, preview: bool) -> anyhow::Result<Action> {
|
pub async fn print_changes(input: &str) -> anyhow::Result<Action> {
|
||||||
let noil_index = parse_input(input).context("parse input")?;
|
let noil_index = parse_input(input).context("parse input")?;
|
||||||
|
|
||||||
fn print_op(key: &str, index: Option<&str>, path: Option<&Path>) {
|
fn print_op(key: &str, index: Option<&str>, path: Option<&Path>) {
|
||||||
@@ -64,11 +64,6 @@ pub async fn print_changes(input: &str, preview: bool) -> anyhow::Result<Action>
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if preview {
|
|
||||||
return Ok(Action::Quit);
|
|
||||||
}
|
|
||||||
|
|
||||||
eprint!("\nApply changes? (y (yes) / n (abort) / E (edit)): ");
|
eprint!("\nApply changes? (y (yes) / n (abort) / E (edit)): ");
|
||||||
let mut stderr = std::io::stderr();
|
let mut stderr = std::io::stderr();
|
||||||
stderr.flush()?;
|
stderr.flush()?;
|
||||||
|
Reference in New Issue
Block a user