/* ==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-- Dia-Args Copyright (C) 2018-2019, 2021-2024 Anonymous There are several releases over multiple years, they are listed as ranges, such as: "2018-2019". This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 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 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . ::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::-- */ use { std::borrow::Cow, dia_args::{ Result, docs::{Cmd, Docs, Option, Project}, }, }; /// # Docs tests /// /// You should run this test with `--nocapture` flag and watch the output. #[test] fn docs() -> Result<()> { let docs = Cow::Owned(format!( concat!( "- If set to '{}', trim input string before hashing it.\n", "- This option is only available for calculating hash of an input string.", " It is NOT available for calculating hashes from stdin or files. It's also NOT available if input file is too large.", " Note that this is a test documentation. So take it easy :-)", ), true, )); let trim_option = Option::new(&["-t", "--trim"], true, &[], Some(&false), docs); let format_option = Option::new(&["--format"], false, &["hex", "hex-array"], Some("hex"), Cow::Borrowed("Format for output hashes.")); let options = dia_args::make_options![&trim_option, &format_option,]; let help_cmd = Cmd::new("help", "Prints help and exits.".into(), None); let hash_cmd = Cmd::new( "hash", concat!( "Hash an input string or stdin or input file(s).\n", "\n", "Supported algorithms:", " Keccak-224, Keccak-256, Keccak-384, Keccak-512, SHA3-224, SHA3-256, SHA3-384, SHA3-512, Shake-128, Shake-256.\n", ).into(), Some(options.clone()), ); let mut docs = Docs::new( "Dia-Hammer".into(), Cow::Owned(format!( concat!( "Project: https://bitbucket.org/de-marco/hammer\n", "License: Nice License\n", "This project follows Semantic Versioning 2.0.0\n", "\n", "Features:\n", "\n", "- Calculating hashes of data via Keccak algorithms. Supported algorithms are: please see 'help' command for details.\n", "- Meow.\n", "- Woof.\n\n", "{}", ), dia_args::DIA_ARGS_FILE_FORMAT, )), ); docs.options = Some(options.clone()); docs.commands = Some(dia_args::make_cmds![&help_cmd, hash_cmd,]); docs.project = Some(Project::new(None, "Nice License", Some(Cow::Borrowed(include_str!("../COPYING"))))); docs.print()?; Ok(()) }