dia-args 0.59.4

For handling command line arguments
Documentation
/*
==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

Dia-Args

Copyright (C) 2018-2019, 2021-2023  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 <https://www.gnu.org/licenses/>.

::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--
*/

//! # Templates

const HEADER: &str = include_str!("templates/header.rs");
const USES: &str = include_str!("templates/uses.rs");
const IDENTIFIERS: &str = include_str!("templates/identifiers.rs");
const FOOTER: &str = include_str!("templates/footer.rs");

/// # Placeholder for crate name
pub const CRATE_NAME_PLACEHOLDER: &str = ">>>name<<<";

/// # Placeholder for crate code name
pub const CRATE_CODE_NAME_PLACEHOLDER: &str = ">>>code_name<<<";

/// # Placeholder for crate ID
pub const CRATE_ID_PLACEHOLDER: &str = ">>>id<<<";

/// # Placeholder for tag ID
pub const TAG_ID_PLACEHOLDER: &str = ">>>tag_id<<<";

/// # Placeholder for year
pub const YEAR_PLACEHOLDER: &str = ">>>year<<<";

/// # Placeholder for month
pub const MONTH_PLACEHOLDER: &str = ">>>month<<<";

/// # Placeholder for day
pub const DAY_PLACEHOLDER: &str = ">>>day<<<";

/// # Placeholder for `uses`
pub const USES_PLACEHOLDER: &str = ">>>uses<<<";

/// # Gets header
pub fn header<'a>() -> &'a str {
    skip_license_lines(HEADER)
}

/// # Gets uses
pub fn uses<'a>() -> &'a str {
    skip_license_lines(USES)
}

/// # Gets identifiers
///
/// Supported placeholders:
///
/// - [`CRATE_NAME_PLACEHOLDER`][const:CRATE_NAME_PLACEHOLDER]
/// - [`CRATE_CODE_NAME_PLACEHOLDER`][const:CRATE_CODE_NAME_PLACEHOLDER]
/// - [`CRATE_ID_PLACEHOLDER`][const:CRATE_ID_PLACEHOLDER]
/// - [`TAG_ID_PLACEHOLDER`][const:TAG_ID_PLACEHOLDER]
/// - [`YEAR_PLACEHOLDER`][const:YEAR_PLACEHOLDER]
/// - [`MONTH_PLACEHOLDER`][const:MONTH_PLACEHOLDER]
/// - [`DAY_PLACEHOLDER`][const:DAY_PLACEHOLDER]
///
/// [const:CRATE_NAME_PLACEHOLDER]: constant.CRATE_NAME_PLACEHOLDER.html
/// [const:CRATE_CODE_NAME_PLACEHOLDER]: constant.CRATE_CODE_NAME_PLACEHOLDER.html
/// [const:CRATE_ID_PLACEHOLDER]: constant.CRATE_ID_PLACEHOLDER.html
/// [const:TAG_ID_PLACEHOLDER]: constant.TAG_ID_PLACEHOLDER.html
/// [const:YEAR_PLACEHOLDER]: constant.YEAR_PLACEHOLDER.html
/// [const:MONTH_PLACEHOLDER]: constant.MONTH_PLACEHOLDER.html
/// [const:DAY_PLACEHOLDER]: constant.DAY_PLACEHOLDER.html
pub fn identifiers<'a>() -> &'a str {
    skip_license_lines(IDENTIFIERS)
}

/// # Gets footer
pub fn footer<'a>() -> &'a str {
    skip_license_lines(FOOTER)
}

/// # Skips license lines
fn skip_license_lines(content: &str) -> &str {
    const TMP: &str = concat!('*', '/');

    content.find(TMP).map(|i| content[i + TMP.len()..].trim_start()).unwrap_or(content)
}