Clap default value if with result based on given argument

Hi, I'm trying to add a default value to the flag --foo when the shell is set to nushell and I want this default value to be dependent of what the user entered as name
I looked at the documentation for quite some times without finding anything like that, therefore I came here to ask for help

#[derive(Parser, Debug)]
pub struct Init {
	shell: Shell,
	#[clap(long, default_value = "wh")]
	name: String,
	#[clap(long, default_value_if("shell", "nu", Some(format!("{self.name} foo"))))]
	foo: Option<String>,
}

#[derive(clap::ValueEnum, Debug, Clone)]
enum Shell {
	Bash,
	Fish,
	Zsh,
	Nu,
}

idk the exact internals of clap but what you ask is likely not possible since that struct is likely populated at the end of the argument parsing.

i also think that the idea is flawed your argument parsing should be agnostic to the content of said arguments and your logic should run afterwards

I don't think this is possible. If you look at default_value_if documentation:

pub fn default_value_if(
    self,
    arg_id: impl Into<Id>,
    predicate: impl Into<ArgPredicate>,
    default: impl IntoResettable<OsStr>,
) -> Arg

you will see that the value should be something implementing IntoResettable<OsStr> and in the end that is not implemented for String (even if the interpolation of self.name would work, and I don't think it would).

Why don't you just do:

let foo = match args.shell {
    Shell::Nu => Some(args.name),
    _ => None
};

It is a one-liner after all...