Compare commits
1 Commits
cuddle-ple
...
da97e3179a
Author | SHA1 | Date | |
---|---|---|---|
|
da97e3179a |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -6,24 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.2.0] - 2025-08-24
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- move also creates parent dir on destination
|
|
||||||
|
|
||||||
## [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
|
## [0.1.0] - 2025-08-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -431,7 +431,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "noil"
|
name = "noil"
|
||||||
version = "0.1.1"
|
version = "0.0.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
noil = { path = "crates/noil" }
|
noil = { path = "crates/noil" }
|
||||||
|
@@ -40,13 +40,10 @@ pub struct EditCommand {
|
|||||||
|
|
||||||
impl EditCommand {
|
impl EditCommand {
|
||||||
pub async fn execute(&self) -> anyhow::Result<()> {
|
pub async fn execute(&self) -> anyhow::Result<()> {
|
||||||
let mut small_id = Vec::new();
|
let mut small_id = Vec::with_capacity(8);
|
||||||
|
for id in small_id.iter_mut() {
|
||||||
for _ in 0..8 {
|
*id = encode_rand::ALPHABET
|
||||||
small_id.push(
|
[rand::random_range(0..(encode_rand::ALPHABET_LEN as u8)) as usize];
|
||||||
encode_rand::ALPHABET
|
|
||||||
[rand::random_range(0..(encode_rand::ALPHABET_LEN as u8)) as usize],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
let small_id = String::from_utf8_lossy(&small_id);
|
let small_id = String::from_utf8_lossy(&small_id);
|
||||||
|
|
||||||
@@ -65,20 +62,9 @@ impl EditCommand {
|
|||||||
.await
|
.await
|
||||||
.context("create temp file for noil")?;
|
.context("create temp file for noil")?;
|
||||||
|
|
||||||
let path = &self
|
let output = get_outputs(&self.get_path().await.context("get path")?, true)
|
||||||
.get_path()
|
|
||||||
.await
|
.await
|
||||||
.context("get path")
|
.context("get output")?;
|
||||||
.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())
|
file.write_all(output.as_bytes())
|
||||||
.await
|
.await
|
||||||
.context("write contents for edit")?;
|
.context("write contents for edit")?;
|
||||||
@@ -165,16 +151,10 @@ impl EditCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
let parent_path = path
|
return path
|
||||||
.parent()
|
.parent()
|
||||||
.map(|p| p.to_path_buf())
|
.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())
|
Ok(path.clone())
|
||||||
@@ -328,14 +308,6 @@ pub async fn apply(input: &str, options: ApplyOptions) -> anyhow::Result<()> {
|
|||||||
anyhow::bail!("destination already exists cannot move");
|
anyhow::bail!("destination already exists cannot move");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(parent) = existing.path.parent()
|
|
||||||
&& !parent.exists()
|
|
||||||
{
|
|
||||||
tokio::fs::create_dir_all(&parent)
|
|
||||||
.await
|
|
||||||
.context("failed to create dest for move")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
tokio::fs::rename(&existing.path, path)
|
tokio::fs::rename(&existing.path, path)
|
||||||
.await
|
.await
|
||||||
.context("move path")?;
|
.context("move path")?;
|
||||||
@@ -362,7 +334,7 @@ pub async fn apply(input: &str, options: ApplyOptions) -> anyhow::Result<()> {
|
|||||||
.map(|i| i.display().to_string())
|
.map(|i| i.display().to_string())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
file.write_all(open_files.join(" ").as_bytes())
|
file.write_all(open_files.join("\n").as_bytes())
|
||||||
.await
|
.await
|
||||||
.context("write chosen files")?;
|
.context("write chosen files")?;
|
||||||
file.flush().await.context("flush chosen file")?;
|
file.flush().await.context("flush chosen file")?;
|
||||||
|
Reference in New Issue
Block a user