mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
cli: args can parse unions
This commit is contained in:
@ -154,10 +154,11 @@ fn parseIntoField(
|
|||||||
else => field.type,
|
else => field.type,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we are a struct and have parseCLI, we call that and use
|
// If we are a type that can have decls and have a parseCLI decl,
|
||||||
// that to set the value.
|
// we call that and use that to set the value.
|
||||||
switch (@typeInfo(Field)) {
|
const fieldInfo = @typeInfo(Field);
|
||||||
.Struct => if (@hasDecl(Field, "parseCLI")) {
|
if (fieldInfo == .Struct or fieldInfo == .Union or fieldInfo == .Enum) {
|
||||||
|
if (@hasDecl(Field, "parseCLI")) {
|
||||||
const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).Fn;
|
const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).Fn;
|
||||||
switch (fnInfo.params.len) {
|
switch (fnInfo.params.len) {
|
||||||
// 1 arg = (input) => output
|
// 1 arg = (input) => output
|
||||||
@ -182,8 +183,10 @@ fn parseIntoField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (fieldInfo) {
|
||||||
.Enum => {
|
.Enum => {
|
||||||
@field(dst, field.name) = std.meta.stringToEnum(
|
@field(dst, field.name) = std.meta.stringToEnum(
|
||||||
Field,
|
Field,
|
||||||
|
Reference in New Issue
Block a user