6 Commits

Author SHA1 Message Date
139aa6d75e chore: remove cockroach
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-26 22:35:52 +02:00
a71672823c feat: update demo
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-26 22:16:34 +02:00
c0bd8c0d36 feat: add help text for preview
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-26 22:05:46 +02:00
dadec333d4 chore(release): v0.0.5 (#8)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.0.5

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: #8
2025-07-26 21:48:14 +02:00
18411bc52c feat: actually copy files
All checks were successful
continuous-integration/drone/push Build is passing
2025-07-26 21:44:51 +02:00
6ce8f3e9b4 chore(release): v0.0.4 (#7)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.0.4

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: #7
2025-07-26 21:08:34 +02:00
8 changed files with 51 additions and 26 deletions

View File

@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.0.5] - 2025-07-26
### Added
- actually copy files
## [0.0.4] - 2025-07-26
### Added
- can now do file operations
### Other
- test
- replace url
## [0.0.3] - 2025-07-26
### Added

2
Cargo.lock generated
View File

@@ -389,7 +389,7 @@ dependencies = [
[[package]]
name = "noil"
version = "0.0.3"
version = "0.0.5"
dependencies = [
"ansi_term",
"anyhow",

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"
[workspace.package]
version = "0.0.3"
version = "0.0.5"
[workspace.dependencies]
noil = { path = "crates/noil" }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -6,7 +6,10 @@ use crate::{
};
#[derive(clap::Parser)]
pub struct ApplyCommand {}
pub struct ApplyCommand {
#[arg(long = "commit")]
commit: bool,
}
impl ApplyCommand {
pub async fn execute(&self) -> anyhow::Result<()> {
@@ -17,11 +20,19 @@ impl ApplyCommand {
let input = String::from_utf8_lossy(&buffer);
let action = print_changes(&input).await?;
match action {
Action::Quit => Ok(()),
Action::Apply { original } => apply(&original).await,
Action::Edit => todo!(),
if !self.commit {
let action = print_changes(&input, !self.commit).await?;
let res = match action {
Action::Quit => Ok(()),
Action::Apply { original } => apply(&original).await,
Action::Edit => todo!(),
};
eprintln!("\nin preview mode: add (--commit) to perform actions");
res
} else {
apply(&input).await
}
}
}

View File

@@ -17,6 +17,8 @@ use crate::{
parse,
};
const PREVIEW: bool = false;
#[derive(Parser)]
pub struct EditCommand {
#[arg()]
@@ -68,7 +70,7 @@ impl EditCommand {
.await
.context("read noil file")?;
let res = print_changes(&noil_content).await;
let res = print_changes(&noil_content, PREVIEW).await;
let action = match res {
Ok(a) => a,
@@ -175,6 +177,7 @@ pub async fn apply(input: &str) -> anyhow::Result<()> {
if existing.path.is_dir() {
tracing::debug!("copying dir");
copy(&existing.path, path).await?;
continue;
}
tokio::fs::copy(&existing.path, &path)
@@ -235,6 +238,9 @@ async fn copy(source: &Path, dest: &Path) -> anyhow::Result<()> {
for entry in walkdir::WalkDir::new(source) {
let entry = entry?;
tracing::debug!("copying path: {}", entry.path().display());
paths.push(entry.path().strip_prefix(source)?.to_path_buf());
}
@@ -260,10 +266,12 @@ async fn copy_path(src: &Path, dest: &Path) -> anyhow::Result<()> {
}
if src.is_dir() {
tracing::info!("copying dir: {}", dest.display());
tokio::fs::create_dir_all(&dest).await.context("copy dir")?;
}
if dest.is_file() {
if src.is_file() {
tracing::info!("copying file: {}", dest.display());
tokio::fs::copy(&src, &dest).await.context("copy file")?;
}

View File

@@ -14,7 +14,7 @@ pub enum Action {
Edit,
}
pub async fn print_changes(input: &str) -> anyhow::Result<Action> {
pub async fn print_changes(input: &str, preview: bool) -> anyhow::Result<Action> {
let noil_index = parse_input(input).context("parse input")?;
fn print_op(key: &str, index: Option<&str>, path: Option<&Path>) {
@@ -64,6 +64,11 @@ pub async fn print_changes(input: &str) -> anyhow::Result<Action> {
_ => {}
}
}
if preview {
return Ok(Action::Quit);
}
eprint!("\nApply changes? (y (yes) / n (abort) / E (edit)): ");
let mut stderr = std::io::stderr();
stderr.flush()?;

View File

@@ -1,15 +0,0 @@
version: "3"
services:
crdb:
restart: 'always'
image: 'cockroachdb/cockroach:v23.1.14'
command: 'start-single-node --advertise-addr 0.0.0.0 --insecure'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health?ready=1"]
interval: '10s'
timeout: '30s'
retries: 5
start_period: '20s'
ports:
- 8080:8080
- '26257:26257'