diff --git a/TODO.md b/TODO.md index 67a3aac..f4b8ac7 100644 --- a/TODO.md +++ b/TODO.md @@ -7,7 +7,15 @@ [ ] 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 + ### Currently working on ## Finished diff --git a/src/main.rs b/src/main.rs index af8c9cb..d91dc76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,6 @@ 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 start editing it and "snp snippet_name argument" 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 {} diff --git a/src/wrapper_functions.rs b/src/wrapper_functions.rs index f82254e..8036b43 100644 --- a/src/wrapper_functions.rs +++ b/src/wrapper_functions.rs @@ -3,6 +3,7 @@ //! All functions included should either take a Cli object and return a SnippetError //! or be a helper function for such a function +use clap::CommandFactory; #[allow(unused)] // Mandatory because of how test and rust-analyser work use edit::edit; @@ -224,7 +225,13 @@ pub fn list_snippets(_cli: &Cli) -> Result<(), SnippetError> { /// Print the snippet to stdout pub fn print_snippet(cli: &Cli) -> Result<(), SnippetError> { - // Try to load the snippet + // Try to load the snippet i + if let None = cli.snippet { + // This wonky hack exists because of subcommands + // It could also be checked when populating, but is way easier this + Cli::command().print_long_help()?; + return Ok(()); + } let (_, f) = match check_dir_and_open(cli.snippet.as_ref().unwrap())? { FileStatus::Opened((p, f)) => (p, f), FileStatus::NotFound(p) => return Err(SnippetError::NotFound(p)),