iceoryx2_cli/
cli.rs

1// Copyright (c) 2024 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13use colored::*;
14
15pub fn help_template(cli_name: &str, show_external_commands: bool) -> String {
16    let mut template = format!(
17        "{{about}}\n\n{}{}{}[OPTIONS] [COMMAND]\n\n{}\n{{options}}\n\n{}\n{{subcommands}}",
18        "Usage: ".bright_green().bold(),
19        cli_name.bold(),
20        " ".bold(),
21        "Options:".bright_green().bold(),
22        "Commands:".bright_green().bold()
23    );
24
25    if show_external_commands {
26        template.push_str(&format!(
27            "\n{}{}",
28            "  ...            ".bold(),
29            "See external installed commands with --list"
30        ));
31    }
32
33    template
34}