Compare commits

..

7 Commits
1.0.5 ... main

4 changed files with 30 additions and 33 deletions

View File

@ -1,7 +1,7 @@
[package] [package]
name = "snp" name = "snp"
authors = ["Dandaedre"] authors = ["Dandaedre"]
version = "1.0.5" version = "1.0.6"
edition = "2021" edition = "2021"
[features] [features]

12
TODO.md
View File

@ -6,26 +6,18 @@
[ ] Case sensitivity windows [ ] Case sensitivity windows
[ ] Use Ok for results instead of prints [ ] Use Ok for results instead of prints
[ ] Use priority instead of a cursed match statement [ ] Use priority instead of a cursed match statement
[ ] Correct the newline problem (with toml ?)
[ ] Have a method to get name, path and all with a custom error on unwrap [ ] Have a method to get name, path and all with a custom error on unwrap
### Currently working on ### Currently working on
[-] Add some examples with --example
[ ] Have an actual human give feedback on the error name readability [ ] Have an actual human give feedback on the error name readability
## Finished ## Finished
[*] Edit -> edit-all [*] Add some examples with --example
[*] Message on delete
[*] Remove last return
[*] Remove the prerequiste of name for --list
[*] Better message on no erase
[*] Comment on no op with replace
[*] Add example to the tests on actions, wrapper_functions
[*] Double backslash windows
## Posponed or rendered useless ## Posponed or rendered useless
[x] Chain the methods when possible with result ? [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) [ ] 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 [ ] Change all uncatchables errors to expect to be more helpful or change them to better errors
[ ] Document non coverage [ ] Document non coverage
[ ] Correct the newline problem (with toml ?)
[*] Error: Delete, unclear ? [*] Error: Delete, unclear ?

View File

@ -11,17 +11,17 @@ mod snippet;
mod tokenizer; mod tokenizer;
mod wrapper_functions; mod wrapper_functions;
/// SNP an utility to create and manage Snippets of code /// SNP an utility to create and manage Snippets of code
/// - /// _
/// Use "snp -c -E snippet_name" to create a new Snippet and /// Use "snp -c -E snippet_name" to create a new Snippet and
/// directly start editing it, then use"snp snippet_name" to use it. /// directly start editing it, then use"snp snippet_name" to use it.
/// You can use "{}" or "{0}" in your Snippet to later format it to /// You can use "{}" or "{0}" in your Snippet to later format it to
/// your needs as would python .format() or rust format!("",) work /// your needs as would python .format() or rust format!("",) work
/// Doing so will need as many default arguments to fill the command /// Doing so will need as many default arguments to fill the command
/// than the total count of {} /// than the total count of {}
/// - /// -
/// You can get a working example with --example witch will guide you /// You can get a working example with --example witch will guide you
/// through all the basic steps for snippet creation and edition /// through all the basic steps for snippet creation and edition
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(author, version, about, verbatim_doc_comment)] #[command(author, version, about, verbatim_doc_comment)]
pub struct Cli { pub struct Cli {

View File

@ -280,26 +280,31 @@ pub fn create_example(_cli: &Cli) -> Result<(), SnippetError> {
let mut path = config_folder()?; let mut path = config_folder()?;
path.push("unique_example.yaml"); path.push("unique_example.yaml");
println!( println!(
"The snippet unique_example was created. You can use the following command to launch an editor and begin editing it: "The snippet unique_example was created. You can use the following command to launch an editor and begin editing the content of the example:
$ snp unique_example -E $ snp unique_example -e
Note that only the content of the text is editable in this mode, to edit the whole snippet use:
$ snp unique_example -E
Once you are done with the editing, you can try using the snippet with: Once you are done with the editing, you can try using the snippet with:
$ snp unique_example $ snp unique_example
or
$ snp unique_example random parameters separated by spaces
If you wish to delete the snippet, you can use the following command: If you wish to delete the snippet, you can use the following command:
$ snp -d unique_example" $ snp -d unique_example"
); );
let arguments = vec!["Argument 1", "Argument 2", "Foo", "Bar"]; let arguments = vec!["Argument 1", "Argument 2", "Foo", "Bar"];
let text = "This is a snippet created as an example. let text = "This is a snippet created as an example.
You can type several lines of code to help you in your daily coding process. You can type several lines of code to help you in your daily coding process.
This snippet manager accepts either {} as a argument placeholder This snippet manager accepts either {} as a argument placeholder
and will fill it with Argument 1, the first argument. and will fill it with every subsequent argument provided.
You can also use {0} to have the first argument somewhere else. You can also write {0}, {3}, etc. to use a specific argument
Or {3} to skip to the last argument and finish with {} {} {} instead of using them in order.
If you only needed to edit this code part and not the snippet, To edit only this text and not the whole code, you can use
you can use instead `snp unique_example -e` (not -E). `snp unique_example -e` and to edit all parameters
Please consult the --help for the full list of commands ! (name, default arguments and content) use -E or --edit-all.
"; Please consult the --help for the full list of commands !";
let snp = Snippet::new( let snp = Snippet::new(
"unique_example".to_string(), "unique_example".to_string(),
arguments.iter().map(|s| s.to_string()).collect(), arguments.iter().map(|s| s.to_string()).collect(),