ctb_formats_warc/warc.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3This file is part of Collective Toolbox, a database and document workspace and utilities.
4Copyright (C) 2026 Collective Toolbox Developers
5Contact: info@collectivetoolbox.com
6
7This program is free software: you can redistribute it and/or modify it under
8the terms of the GNU Affero General Public License as published by the Free
9Software Foundation, either version 3 of the License, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
15
16You should have received a copy of the GNU Affero General Public License along
17with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20//! Web `ARChive` (WARC) file processing and warcat utility wrapper.
21
22#[allow(
23 unused_imports,
24 clippy::wildcard_imports,
25 reason = "Standard workspace crate prelude"
26)]
27pub(crate) use ctb_utilities::*;
28
29use clap::CommandFactory;
30
31/// Programmatic wrapper around warcat tool
32pub fn run_warcat<I, T>(args: I) -> i32
33where
34 I: IntoIterator<Item = T>,
35 T: Into<std::ffi::OsString> + Clone,
36{
37 warcat::app::run_from(args)
38}
39
40/// Returns the clap Command representation for the warcat tool.
41pub fn warcat_command() -> clap::Command {
42 warcat::app::arg::Args::command().name("warcat")
43}
44
45#[cfg(test)]
46#[allow(
47 clippy::panic,
48 clippy::expect_used,
49 clippy::unwrap_used,
50 clippy::unwrap_in_result,
51 clippy::panic_in_result_fn,
52 clippy::indexing_slicing,
53 clippy::arithmetic_side_effects,
54 reason = "Standard repository test boilerplate"
55)]
56mod tests {
57 use super::*;
58
59 #[crate::ctb_test]
60 fn test_warcat_help() {
61 let args = vec!["warcat".to_string(), "help".to_string()];
62 let exit_code = run_warcat(args);
63 assert_eq!(exit_code, 0);
64 }
65}