Closed avnerbarr closed 2 years ago
you could add a debug derivation like so: #[derive(StructOpt, Debug)]
and then print like println!("{:?}, new_opts);
or even println!("{:#?}", new_opts);
AFAIK, that's not possible, and it will be a quite complicated feature, relying deeply in clap internal.
Adding to this I want to use structopt
for IPC with a forked child process, and so I'd like to be able to go from an Opt
structure to a Vec
/Iterator
of argument strings.
ie.
enum Opt {
#[structopt(short, long)]
host_name: String,
}
// ["--host_name", "my-server"]
(Opt { host_name: "my-server".to_owned() }).args()
If this was possible then you could emit debugging info by doing:
println!("{:?}", op.args())
@TeXitoi would you be open to a PR implementing this?
Better to propose to clapv3
This is an enhancement, and structopt is now feature frozen.
I want to get the string representation leading to a particular Opt instance (after I've modified it).
for instance