Adds ore messages
This commit is contained in:
parent
2c48bbd4e7
commit
cb2c711129
20
TODO.md
20
TODO.md
|
|
@ -1,27 +1,27 @@
|
|||
## TODO
|
||||
[ ] Benchmarks
|
||||
[ ] Better use of file modes
|
||||
[ ] Document non coverage
|
||||
[ ] Find a solution for the .badpocalypse
|
||||
[ ] Edit args only
|
||||
[ ] Double backslash win
|
||||
[ ] Remove last return
|
||||
[ ] Remove the prerequiste of name for --list
|
||||
[ ] Add some examples with --example
|
||||
[ ] Double backslash windows
|
||||
[ ] Case sensitivity windows
|
||||
[ ] Bigger message for print "The snippet name ca be found at "i
|
||||
[ ] Message on delete
|
||||
[ ] Investigate clap on -rfe etc
|
||||
[ ] Better message on no errase
|
||||
[ ] Edit -> edit-all
|
||||
[ ] Bigger message for print "The snippet name can be found at "
|
||||
[ ] Use Ok for results instead of prints
|
||||
|
||||
### Currently working on
|
||||
[ ] Add some examples with --example
|
||||
|
||||
## Finished
|
||||
[*] Edit -> edit-all
|
||||
[*] Message on delete
|
||||
[*] Remove last return
|
||||
[*] Remove the prerequiste of name for --list
|
||||
[*] Better message on no erase
|
||||
[*] Comment on no op with replace
|
||||
|
||||
## Posponed or rendered useless
|
||||
[x] Chain the methods when possible with result ?
|
||||
[ ] Make a lib for dynamic_format and snippets (impl make a trait for have .id() and other future t)
|
||||
[ ] Change all uncatchables errors to expect to be more helpful or change them to better errors
|
||||
[ ] Document non coverage
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@ mod test {
|
|||
vec![Actions::Create]
|
||||
),
|
||||
(false_cli!("snp", "-l"), vec![Actions::List]),
|
||||
// (false_cli!("snp", "-l"), vec![Actions::List]),
|
||||
(false_cli!("snp"), vec![Actions::Show]), // It's an acceptable error
|
||||
// (false_cli!("snp", "-l"), vec![Actions::List]),
|
||||
);
|
||||
for (cli, res) in group.iter() {
|
||||
println!("Testing {:?}..actions expected {:?}", cli, res);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub struct Cli {
|
|||
/// Launch the editor and edit the whole snippet
|
||||
#[arg(
|
||||
short = 'E',
|
||||
long = "Edit",
|
||||
long = "edit-all",
|
||||
default_value_t = false,
|
||||
requires = "mandatory"
|
||||
)]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use clap::CommandFactory;
|
|||
use edit::edit;
|
||||
|
||||
use std::fs::{self, create_dir_all};
|
||||
use std::io::{read_to_string, Write};
|
||||
use std::io::{self, read_to_string, Write};
|
||||
use std::{env, fs::File, path::PathBuf};
|
||||
|
||||
use crate::errors::SnippetError;
|
||||
|
|
@ -60,6 +60,7 @@ pub fn rename_snippet(cli: &Cli) -> Result<(), SnippetError> {
|
|||
// Check wether the snippet exitsts
|
||||
let new_name = cli.rename.as_ref().unwrap();
|
||||
if new_name == cli.snippet.as_ref().unwrap() {
|
||||
println!("The original and new snippet name are the same, skipping...");
|
||||
return Ok(()); // The noop is a success ?
|
||||
}
|
||||
let (f, oldpath) = match check_dir_and_open(cli.snippet.as_ref().unwrap())? {
|
||||
|
|
@ -245,7 +246,8 @@ pub fn print_snippet(cli: &Cli) -> Result<(), SnippetError> {
|
|||
// Print the snippet
|
||||
let f_str = dynamic_formatter::dynamic_format(&snp.content, final_args)?;
|
||||
|
||||
println!("{}", f_str);
|
||||
print!("{}", f_str);
|
||||
io::stdout().flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +255,12 @@ pub fn print_snippet(cli: &Cli) -> Result<(), SnippetError> {
|
|||
pub fn delete_snippet(cli: &Cli) -> Result<(), SnippetError> {
|
||||
let mut path = config_folder()?;
|
||||
path.push(format!("{}.yaml", cli.snippet.as_ref().unwrap()));
|
||||
std::fs::remove_file(path)?;
|
||||
std::fs::remove_file(&path)?;
|
||||
println!(
|
||||
"The snippet \"{}\" was successfully deleted.",
|
||||
// path.file_name().unwrap().to_str().unwrap()
|
||||
cli.snippet.as_ref().unwrap()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
/// The status of the request after the path was attempted to be opened
|
||||
|
|
|
|||
Reference in New Issue