Corrects bugs on no args and doc not showing fully

This commit is contained in:
beffroi 2023-05-24 11:56:42 +02:00
parent 5cd297b1da
commit 2c48bbd4e7
3 changed files with 17 additions and 3 deletions

10
TODO.md
View File

@ -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

View File

@ -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 {}

View File

@ -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 <name>
// Try to load the snippet <name>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)),