5 Commits

Author SHA1 Message Date
6129401cb5 chore(release): v0.1.2 (#11)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.1.2

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: #11
2025-08-08 14:52:40 +02:00
1bc58a2047 feat: default to current dir if no file could be found
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-08 14:52:19 +02:00
de913cd375 chore: should be space instead
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-04 11:42:31 +02:00
d1b20ee5aa chore(release): v0.1.1 (#10)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.1.1

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: #10
2025-08-04 11:12:16 +02:00
da00f41205 fix: if path is empty default to .
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-04 10:47:47 +02:00
4 changed files with 44 additions and 11 deletions

View File

@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.1.2] - 2025-08-08
### Added
- default to current dir if no file could be found
### Other
- should be space instead
## [0.1.1] - 2025-08-04
### Fixed
- if path is empty default to `.`
## [0.1.0] - 2025-08-03
### Added

2
Cargo.lock generated
View File

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

View File

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

View File

@@ -40,10 +40,13 @@ pub struct EditCommand {
impl EditCommand {
pub async fn execute(&self) -> anyhow::Result<()> {
let mut small_id = Vec::with_capacity(8);
for id in small_id.iter_mut() {
*id = encode_rand::ALPHABET
[rand::random_range(0..(encode_rand::ALPHABET_LEN as u8)) as usize];
let mut small_id = Vec::new();
for _ in 0..8 {
small_id.push(
encode_rand::ALPHABET
[rand::random_range(0..(encode_rand::ALPHABET_LEN as u8)) as usize],
);
}
let small_id = String::from_utf8_lossy(&small_id);
@@ -62,9 +65,20 @@ impl EditCommand {
.await
.context("create temp file for noil")?;
let output = get_outputs(&self.get_path().await.context("get path")?, true)
let path = &self
.get_path()
.await
.context("get output")?;
.context("get path")
.inspect_err(|e| {
tracing::warn!(
"error: file path doesn't exist, defaulting to current working dir: {e}"
)
})
.unwrap_or_else(|_| PathBuf::from("."));
let output = get_outputs(path, true)
.await
.context(format!("get output: {}", path.display()))?;
file.write_all(output.as_bytes())
.await
.context("write contents for edit")?;
@@ -151,10 +165,16 @@ impl EditCommand {
}
if path.is_file() {
return path
let parent_path = path
.parent()
.map(|p| p.to_path_buf())
.ok_or(anyhow::anyhow!("parent doesn't exist for file"));
.ok_or(anyhow::anyhow!("parent doesn't exist for file"))?;
if parent_path.display().to_string() == "" {
return Ok(PathBuf::from("."));
}
return Ok(parent_path);
}
Ok(path.clone())
@@ -334,7 +354,7 @@ pub async fn apply(input: &str, options: ApplyOptions) -> anyhow::Result<()> {
.map(|i| i.display().to_string())
.collect::<Vec<_>>();
file.write_all(open_files.join("\n").as_bytes())
file.write_all(open_files.join(" ").as_bytes())
.await
.context("write chosen files")?;
file.flush().await.context("flush chosen file")?;