mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-19 05:13:44 +08:00
BuiltinData to use const constructor function
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
Some checks are pending
make test / ubuntu (push) Waiting to run
make test / ubuntu-32bit-static-pcre2 (push) Waiting to run
make test / ubuntu-asan (push) Waiting to run
make test / macos (push) Waiting to run
Rust checks / rustfmt (push) Waiting to run
Rust checks / clippy (push) Waiting to run
This makes the list of builtins one line per builtin. No functional change.
This commit is contained in:
parent
0b68fbfd85
commit
7e516925e9
|
@ -109,254 +109,77 @@ struct BuiltinData {
|
||||||
func: BuiltinCmd,
|
func: BuiltinCmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BuiltinData {
|
||||||
|
const fn new(name: &'static wstr, func: BuiltinCmd) -> Self {
|
||||||
|
Self { name, func }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Data about all the builtin commands in fish.
|
// Data about all the builtin commands in fish.
|
||||||
// Functions that are bound to builtin_generic are handled directly by the parser.
|
// Functions that are bound to builtin_generic are handled directly by the parser.
|
||||||
// NOTE: These must be kept in sorted order!
|
// NOTE: These must be kept in sorted order!
|
||||||
const BUILTIN_DATAS: &[BuiltinData] = &[
|
const BUILTIN_DATAS: &[BuiltinData] = &[
|
||||||
BuiltinData {
|
BuiltinData::new(L!("."), source::source),
|
||||||
name: L!("."),
|
BuiltinData::new(L!(":"), builtin_true),
|
||||||
func: source::source,
|
BuiltinData::new(L!("["), test::test), // ]
|
||||||
},
|
BuiltinData::new(L!("_"), builtin_gettext),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("abbr"), abbr::abbr),
|
||||||
name: L!(":"),
|
BuiltinData::new(L!("and"), builtin_generic),
|
||||||
func: builtin_true,
|
BuiltinData::new(L!("argparse"), argparse::argparse),
|
||||||
},
|
BuiltinData::new(L!("begin"), builtin_generic),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("bg"), bg::bg),
|
||||||
name: L!("["), // ]
|
BuiltinData::new(L!("bind"), bind::bind),
|
||||||
func: test::test,
|
BuiltinData::new(L!("block"), block::block),
|
||||||
},
|
BuiltinData::new(L!("break"), builtin_break_continue),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("breakpoint"), builtin_breakpoint),
|
||||||
name: L!("_"),
|
BuiltinData::new(L!("builtin"), builtin::builtin),
|
||||||
func: builtin_gettext,
|
BuiltinData::new(L!("case"), builtin_generic),
|
||||||
},
|
BuiltinData::new(L!("cd"), cd::cd),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("command"), command::command),
|
||||||
name: L!("abbr"),
|
BuiltinData::new(L!("commandline"), commandline::commandline),
|
||||||
func: abbr::abbr,
|
BuiltinData::new(L!("complete"), complete::complete),
|
||||||
},
|
BuiltinData::new(L!("contains"), contains::contains),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("continue"), builtin_break_continue),
|
||||||
name: L!("and"),
|
BuiltinData::new(L!("count"), count::count),
|
||||||
func: builtin_generic,
|
BuiltinData::new(L!("disown"), disown::disown),
|
||||||
},
|
BuiltinData::new(L!("echo"), echo::echo),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("else"), builtin_generic),
|
||||||
name: L!("argparse"),
|
BuiltinData::new(L!("emit"), emit::emit),
|
||||||
func: argparse::argparse,
|
BuiltinData::new(L!("end"), builtin_generic),
|
||||||
},
|
BuiltinData::new(L!("eval"), eval::eval),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("exec"), builtin_generic),
|
||||||
name: L!("begin"),
|
BuiltinData::new(L!("exit"), exit::exit),
|
||||||
func: builtin_generic,
|
BuiltinData::new(L!("false"), builtin_false),
|
||||||
},
|
BuiltinData::new(L!("fg"), fg::fg),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("for"), builtin_generic),
|
||||||
name: L!("bg"),
|
BuiltinData::new(L!("function"), builtin_generic),
|
||||||
func: bg::bg,
|
BuiltinData::new(L!("functions"), functions::functions),
|
||||||
},
|
BuiltinData::new(L!("history"), history::history),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("if"), builtin_generic),
|
||||||
name: L!("bind"),
|
BuiltinData::new(L!("jobs"), jobs::jobs),
|
||||||
func: bind::bind,
|
BuiltinData::new(L!("math"), math::math),
|
||||||
},
|
BuiltinData::new(L!("not"), builtin_generic),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("or"), builtin_generic),
|
||||||
name: L!("block"),
|
BuiltinData::new(L!("path"), path::path),
|
||||||
func: block::block,
|
BuiltinData::new(L!("printf"), printf::printf),
|
||||||
},
|
BuiltinData::new(L!("pwd"), pwd::pwd),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("random"), random::random),
|
||||||
name: L!("break"),
|
BuiltinData::new(L!("read"), read::read),
|
||||||
func: builtin_break_continue,
|
BuiltinData::new(L!("realpath"), realpath::realpath),
|
||||||
},
|
BuiltinData::new(L!("return"), r#return::r#return),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("set"), set::set),
|
||||||
name: L!("breakpoint"),
|
BuiltinData::new(L!("set_color"), set_color::set_color),
|
||||||
func: builtin_breakpoint,
|
BuiltinData::new(L!("source"), source::source),
|
||||||
},
|
BuiltinData::new(L!("status"), status::status),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("string"), string::string),
|
||||||
name: L!("builtin"),
|
BuiltinData::new(L!("switch"), builtin_generic),
|
||||||
func: builtin::builtin,
|
BuiltinData::new(L!("test"), test::test),
|
||||||
},
|
BuiltinData::new(L!("time"), builtin_generic),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("true"), builtin_true),
|
||||||
name: L!("case"),
|
BuiltinData::new(L!("type"), r#type::r#type),
|
||||||
func: builtin_generic,
|
BuiltinData::new(L!("ulimit"), ulimit::ulimit),
|
||||||
},
|
BuiltinData::new(L!("wait"), wait::wait),
|
||||||
BuiltinData {
|
BuiltinData::new(L!("while"), builtin_generic),
|
||||||
name: L!("cd"),
|
|
||||||
func: cd::cd,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("command"),
|
|
||||||
func: command::command,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("commandline"),
|
|
||||||
func: commandline::commandline,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("complete"),
|
|
||||||
func: complete::complete,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("contains"),
|
|
||||||
func: contains::contains,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("continue"),
|
|
||||||
func: builtin_break_continue,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("count"),
|
|
||||||
func: count::count,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("disown"),
|
|
||||||
func: disown::disown,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("echo"),
|
|
||||||
func: echo::echo,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("else"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("emit"),
|
|
||||||
func: emit::emit,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("end"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("eval"),
|
|
||||||
func: eval::eval,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("exec"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("exit"),
|
|
||||||
func: exit::exit,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("false"),
|
|
||||||
func: builtin_false,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("fg"),
|
|
||||||
func: fg::fg,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("for"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("function"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("functions"),
|
|
||||||
func: functions::functions,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("history"),
|
|
||||||
func: history::history,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("if"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("jobs"),
|
|
||||||
func: jobs::jobs,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("math"),
|
|
||||||
func: math::math,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("not"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("or"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("path"),
|
|
||||||
func: path::path,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("printf"),
|
|
||||||
func: printf::printf,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("pwd"),
|
|
||||||
func: pwd::pwd,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("random"),
|
|
||||||
func: random::random,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("read"),
|
|
||||||
func: read::read,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("realpath"),
|
|
||||||
func: realpath::realpath,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("return"),
|
|
||||||
func: r#return::r#return,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("set"),
|
|
||||||
func: set::set,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("set_color"),
|
|
||||||
func: set_color::set_color,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("source"),
|
|
||||||
func: source::source,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("status"),
|
|
||||||
func: status::status,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("string"),
|
|
||||||
func: string::string,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("switch"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("test"),
|
|
||||||
func: test::test,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("time"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("true"),
|
|
||||||
func: builtin_true,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("type"),
|
|
||||||
func: r#type::r#type,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("ulimit"),
|
|
||||||
func: ulimit::ulimit,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("wait"),
|
|
||||||
func: wait::wait,
|
|
||||||
},
|
|
||||||
BuiltinData {
|
|
||||||
name: L!("while"),
|
|
||||||
func: builtin_generic,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
assert_sorted_by_name!(BUILTIN_DATAS);
|
assert_sorted_by_name!(BUILTIN_DATAS);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user