Revert "adding tests and updating readme"

This reverts commit 2a86e7adac.
pull/83/head
JhonnyV-V 2024-07-02 16:50:13 -04:00
parent 7d881ce709
commit 0d437475b9
2 changed files with 0 additions and 64 deletions

View File

@ -46,7 +46,6 @@
- [Usage](#usage) - [Usage](#usage)
- [Copy into the clipboard](#copy-into-the-clipboard) - [Copy into the clipboard](#copy-into-the-clipboard)
- [Copy into clipboard on Linux Wayland](#copy-into-clipboard-on-linux-wayland) - [Copy into clipboard on Linux Wayland](#copy-into-clipboard-on-linux-wayland)
- [Copy into clipboard on WSL](#copy-into-clipboard-on-wsl)
- [Save the snapshot](#save-the-snapshot) - [Save the snapshot](#save-the-snapshot)
- [Highlight code block](#highlight-code-block) - [Highlight code block](#highlight-code-block)
- [How to use](#how-to-use) - [How to use](#how-to-use)
@ -170,14 +169,6 @@ Copy screenshots directly into the clipboard is cool, however, it doesn't work w
If you using CodeSnap.nvim on wl-clipboard, you can refer [wl-clip-persist](https://github.com/Linus789/wl-clip-persist), it reads all the clipboard data into memory and then overwrites the clipboard with the data from our memory to persist copied data. If you using CodeSnap.nvim on wl-clipboard, you can refer [wl-clip-persist](https://github.com/Linus789/wl-clip-persist), it reads all the clipboard data into memory and then overwrites the clipboard with the data from our memory to persist copied data.
#### Copy into clipboard on WSL
currently copy to clipboard in WSL works, but it has some potencial issues, inside of wsl normally is not possible to copy an image to the clipboard,
how this works in wsl at this moment is the following, we create an image in the /tmp directory, then we try to execute powershell commands
to copy the image to the clipboard
> [!WARNING]
> If the WSL distro name is not the default or the pretty_name/name in the /etc/os-release this feature will fai
### Save the snapshot ### Save the snapshot
Of course, you can use `CodeSnapSave` command to save the snapshot to path where you defined it in `config.save_path` Of course, you can use `CodeSnapSave` command to save the snapshot to path where you defined it in `config.save_path`
@ -190,8 +181,6 @@ require("codesnap").setup({
-- parsed: "~/Pictures/CodeSnap_y-m-d_at_h:m:s.png" -- parsed: "~/Pictures/CodeSnap_y-m-d_at_h:m:s.png"
-- save_path = "~/Pictures/foo.png" -- save_path = "~/Pictures/foo.png"
-- parsed: "~/Pictures/foo.png" -- parsed: "~/Pictures/foo.png"
-- if you are on wsl and do you want to use a windows path
-- save_path="/mnt/c/Users/user/Pictures/"
save_path = ... save_path = ...
}) })
``` ```

View File

@ -116,56 +116,3 @@ fn generate_random_filename() -> String {
// Combine prefix, random part, and extension // Combine prefix, random part, and extension
format!("codesnap_{}.png", random_part) format!("codesnap_{}.png", random_part)
} }
#[cfg(test)]
mod test {
use std::process::{Command, Stdio};
use super::copy_to_wsl_clipboard;
#[test]
#[cfg(target_os = "linux")]
fn copy_to_wsl_test() -> std::result::Result<(), nvim_oxi::Error> {
if !wsl::is_wsl() {
return Ok(());
}
//not sure about the best way to test this in a dynamic way
//dir example
//"\\\\wsl$\\DistroName\\\\home\\username\\path\\test.png";
let src_path = "";// your director here
return copy_to_wsl_clipboard(src_path);
}
#[test]
#[cfg(target_os = "linux")]
fn check_if_folder_exist() {
if !wsl::is_wsl() {
return;
}
let os_linux_release = sys_info::linux_os_release().unwrap();
let wsl_path = format!(
"\\\\wsl$\\{}",
os_linux_release.name()
);
println!("path {}", wsl_path);
let powershell = Command::new("/mnt/c/Windows//System32/WindowsPowerShell/v1.0/powershell.exe")
.arg("-NoProfile")
.arg("-Command")
.arg(&format!("Test-Path -path \"{}\"", wsl_path))
.stdout(Stdio::piped())
.stderr(Stdio::null())
.output();
let stdout = String::from_utf8(powershell.unwrap().stdout).unwrap();
println!("output {:?}", stdout);
println!("exist {}", stdout == "True\r\n");
println!("does not exist {}", stdout == "False\r\n");
}
}