From 0f7b525a5501af899052fa8847b6bfb745c8f3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Fri, 9 Jun 2023 18:28:19 +0200 Subject: [PATCH] Made -h, --help show license notice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved the help template into its own const, and concatenated it with the interactive notice to append it to the help output. Also, adjusted the license, warranty, and notice strings for increased readability. Signed-off-by: Christina Sørensen --- src/cli.rs | 19 +++++++++++-------- src/utils/strings.rs | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index c70b9a3..b5fa2cc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -15,11 +15,21 @@ // along with this program. If not, see https://www.gnu.org/gpl-3.0.html. use crate::utils::dir::home_dir; +use crate::utils::strings::INTERACTIVE_NOTICE; use clap::{ArgAction, CommandFactory, Parser, Subcommand}; const CONFIG_FILE: &str = "/.config/gg/config.yaml"; +const HELP_TEMPLATE: &str = "\ + {before-help}{name} {version} + {author-with-newline}{about-with-newline} + {usage-heading} {usage} + + {all-args}{after-help} + + "; + //#[clap(author, version, about, long_about = None)] #[derive(Parser, Debug)] #[clap( @@ -31,14 +41,7 @@ const CONFIG_FILE: &str = "/.config/gg/config.yaml"; long_about="A Rust GitOps and linkfarm orchestrator inspired by GNU Stow", subcommand_required=false, arg_required_else_help=true, - help_template="\ - {before-help}{name} {version} - {author-with-newline}{about-with-newline} - {usage-heading} {usage} - - {all-args}{after-help} - - ", + help_template=HELP_TEMPLATE.to_owned()+INTERACTIVE_NOTICE, )] pub struct Args { /// The config file to use diff --git a/src/utils/strings.rs b/src/utils/strings.rs index c25561f..a06c565 100644 --- a/src/utils/strings.rs +++ b/src/utils/strings.rs @@ -17,26 +17,26 @@ /// Contains the notice for interactive programs from the GPLv3's "How to Apply /// These Terms to Your New Programs" pub const INTERACTIVE_NOTICE: &str = "\ - gg Copyright (C) 2023 Christina Sørensen - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. +gg Copyright (C) 2023 Christina Sørensen +This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +This is free software, and you are welcome to redistribute it +under certain conditions; type `show c' for details. "; /// Contains the license part of the long notice for interactive programs from /// the GPLv3's "How to Apply These Terms to Your New Programs" pub const INTERACTIVE_LICENSE: &str = "\ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. "; /// Contains the warranty part of the long notice for interactive programs from /// the GPLv3's "How to Apply These Terms to Your New Programs" pub const INTERACTIVE_WARRANTY: &str = "\ - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. ";