How to use clap without name or about message? #1617
-
Hi All is in the question, any idea how to do this? When I only use this YAML configuration file, it does not works: subcommands:
- cli:
about: "Spawn to the command line interface"
args:
- help:
help: "Prints CLI help information"
short: h
long: help But when I add Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
AFAIK, in clap, the So, Out of curiosity, could you please explain why do you want your program to be nameless? |
Beta Was this translation helpful? Give feedback.
-
Oh okey, I'll explain you! The problem with clap for me is that it begin by the name of the process, and I want to setup an ascii logo with an about message WITHOUT process name. In the past, I was forced to set This is what I want in the cleanest way possible!
|
Beta Was this translation helpful? Give feedback.
-
I believe Please note that template is not propagated to subcomands, and there's currently no way to do that. You will need the use structopt::clap::{App, SubCommand};
const TEMPLATE: &str = "
██╗ ██╗ ██╗ ██████╗██╗██████╗ ██╗ ██╗██╗ ██╗
██║ ██║ ██║██╔════╝██║██╔══██╗ ██║ ██╔╝██║ ██║
██║ ██║ ██║██║ ██║██║ ██║ ██╔═██╗ ╚██╗ ██╔╝
██████╗╚██████╔╝╚██████╗██║██████╔╝ ██║ ██╗ ╚████╔╝
╚═════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═══╝
A Fast, Secure and Distributed KV store with an HTTP API.
Written in Rust by Clint.Network (twitter.com/clint_network)
USAGE:
{usage}
FLAGS:
{flags}
SUBCOMMANDS:
{subcommands}
";
fn main() {
let m = App::new("lucid")
.subcommand(SubCommand::with_name("cli")
.template(TEMPLATE))
.template(TEMPLATE);
println!("{:?}", m.get_matches());
} Output:
|
Beta Was this translation helpful? Give feedback.
-
Oh looks interesting, and is it possible to use that with yaml file? |
Beta Was this translation helpful? Give feedback.
-
Sure, why not? name: lucid
# `&template` means yaml anchor, so this template can be reused easily,
# essential for subcommands
#
# `|` means "block scalar, do not replace newlines with spaces"
# `-` means "trim only trailing newlines"
# `4` is the number of spaces you indent the block with,
# required since your logo starts with a space
#
# see https://yaml-multiline.info/ for details
template: &template |-4
██╗ ██╗ ██╗ ██████╗██╗██████╗ ██╗ ██╗██╗ ██╗
██║ ██║ ██║██╔════╝██║██╔══██╗ ██║ ██╔╝██║ ██║
██║ ██║ ██║██║ ██║██║ ██║ ██╔═██╗ ╚██╗ ██╔╝
██████╗╚██████╔╝╚██████╗██║██████╔╝ ██║ ██╗ ╚████╔╝
╚═════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═══╝
A Fast, Secure and Distributed KV store with an HTTP API.
Written in Rust by Clint.Network (twitter.com/clint_network)
USAGE:
{usage}
FLAGS:
{flags}
SUBCOMMANDS:
{subcommands}
subcommands:
- cli:
# reusing the anchored template, must be done for every subcommand
template: *template
|
Beta Was this translation helpful? Give feedback.
-
Maybe in the future you could add some options to do that, like remove name by default or something like that. Thank you! |
Beta Was this translation helpful? Give feedback.
Sure, why not?