Added examples
This commit is contained in:
parent
f62ac2fe34
commit
63365ee5dc
12
TODO.md
12
TODO.md
|
|
@ -6,26 +6,18 @@
|
|||
[ ] Case sensitivity windows
|
||||
[ ] Use Ok for results instead of prints
|
||||
[ ] 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
|
||||
|
||||
### Currently working on
|
||||
[-] Add some examples with --example
|
||||
[ ] Have an actual human give feedback on the error name readability
|
||||
|
||||
## 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
|
||||
[*] Add example to the tests on actions, wrapper_functions
|
||||
[*] Double backslash windows
|
||||
[*] Add some examples with --example
|
||||
|
||||
## 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
|
||||
[ ] Correct the newline problem (with toml ?)
|
||||
[*] Error: Delete, unclear ?
|
||||
22
src/main.rs
22
src/main.rs
|
|
@ -11,17 +11,17 @@ mod snippet;
|
|||
mod tokenizer;
|
||||
mod wrapper_functions;
|
||||
|
||||
/// SNP an utility to create and manage Snippets of code
|
||||
/// -
|
||||
/// Use "snp -c -E snippet_name" to create a new Snippet and
|
||||
/// 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
|
||||
/// your needs as would python .format() or rust format!("",) work
|
||||
/// Doing so will need as many default arguments to fill the command
|
||||
/// than the total count of {}
|
||||
/// -
|
||||
/// You can get a working example with --example witch will guide you
|
||||
/// through all the basic steps for snippet creation and edition
|
||||
/// SNP an utility to create and manage Snippets of code
|
||||
/// _
|
||||
/// Use "snp -c -E snippet_name" to create a new Snippet and
|
||||
/// 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
|
||||
/// your needs as would python .format() or rust format!("",) work
|
||||
/// Doing so will need as many default arguments to fill the command
|
||||
/// than the total count of {}
|
||||
/// -
|
||||
/// You can get a working example with --example witch will guide you
|
||||
/// through all the basic steps for snippet creation and edition
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, verbatim_doc_comment)]
|
||||
pub struct Cli {
|
||||
|
|
|
|||
|
|
@ -281,30 +281,30 @@ pub fn create_example(_cli: &Cli) -> Result<(), SnippetError> {
|
|||
path.push("unique_example.yaml");
|
||||
println!(
|
||||
"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
|
||||
$ snp unique_example -E
|
||||
|
||||
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
|
||||
|
||||
$ snp unique_example random parameters separated by spaces
|
||||
|
||||
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 text = "This is a snippet created as an example.
|
||||
You can type several lines of code to help you in your daily coding process.
|
||||
This snippet manager accepts either {} as a argument placeholder
|
||||
and will fill it with Argument 1, the first argument.
|
||||
You can also use {0} to have the first argument somewhere else.
|
||||
Or {3} to skip to the last argument and finish with {} {} {}
|
||||
If you only needed to edit this code part and not the snippet,
|
||||
you can use instead `snp unique_example -e` (not -E).
|
||||
Please consult the --help for the full list of commands !
|
||||
";
|
||||
and will fill it with every subsequent argument provided.
|
||||
You can also write {0}, {3}, etc. to use a specific argument
|
||||
instead of using them in order.
|
||||
To edit only this text and not the whole code, you can use
|
||||
`snp unique_example -e` and to edit all parameters
|
||||
(name, default arguments and content) use -E or --edit-all.
|
||||
Please consult the --help for the full list of commands !";
|
||||
let snp = Snippet::new(
|
||||
"unique_example".to_string(),
|
||||
arguments.iter().map(|s| s.to_string()).collect(),
|
||||
|
|
|
|||
Reference in New Issue