mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
bash: support short form boolean options
This commit is contained in:
@ -52,7 +52,10 @@ fn writeBashCompletions(writer: anytype) !void {
|
|||||||
|
|
||||||
for (@typeInfo(Config).Struct.fields) |field| {
|
for (@typeInfo(Config).Struct.fields) |field| {
|
||||||
if (field.name[0] == '_') continue;
|
if (field.name[0] == '_') continue;
|
||||||
try writer.writeAll("config+=\" --" ++ field.name ++ "=\"\n");
|
switch (field.type) {
|
||||||
|
bool, ?bool => try writer.writeAll("config+=\" '--" ++ field.name ++ " '\"\n"),
|
||||||
|
else => try writer.writeAll("config+=\" --" ++ field.name ++ "=\"\n"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try writer.writeAll(
|
try writer.writeAll(
|
||||||
@ -78,7 +81,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
|||||||
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
||||||
const compgenSuffix = "\" -- \"$cur\" ); addSpaces ;;";
|
const compgenSuffix = "\" -- \"$cur\" ); addSpaces ;;";
|
||||||
switch (@typeInfo(field.type)) {
|
switch (@typeInfo(field.type)) {
|
||||||
.Bool => try writer.writeAll(compgenPrefix ++ "true false" ++ compgenSuffix),
|
.Bool => try writer.writeAll("return ;;"),
|
||||||
.Enum => |info| {
|
.Enum => |info| {
|
||||||
try writer.writeAll(compgenPrefix);
|
try writer.writeAll(compgenPrefix);
|
||||||
for (info.fields, 0..) |f, i| {
|
for (info.fields, 0..) |f, i| {
|
||||||
@ -136,7 +139,10 @@ fn writeBashCompletions(writer: anytype) !void {
|
|||||||
for (@typeInfo(options).Struct.fields) |opt| {
|
for (@typeInfo(options).Struct.fields) |opt| {
|
||||||
if (opt.name[0] == '_') continue;
|
if (opt.name[0] == '_') continue;
|
||||||
if (count > 0) try writer.writeAll(" ");
|
if (count > 0) try writer.writeAll(" ");
|
||||||
try writer.writeAll("--" ++ opt.name ++ "=");
|
switch (opt.type) {
|
||||||
|
bool, ?bool => try writer.writeAll("'--" ++ opt.name ++ " '"),
|
||||||
|
else => try writer.writeAll("--" ++ opt.name ++ "="),
|
||||||
|
}
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,7 +178,7 @@ fn writeBashCompletions(writer: anytype) !void {
|
|||||||
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
|
||||||
const compgenSuffix = "\" -- \"$cur\" ); addSpaces ;;";
|
const compgenSuffix = "\" -- \"$cur\" ); addSpaces ;;";
|
||||||
switch (@typeInfo(opt.type)) {
|
switch (@typeInfo(opt.type)) {
|
||||||
.Bool => try writer.writeAll(compgenPrefix ++ "true false" ++ compgenSuffix),
|
.Bool => try writer.writeAll("return ;;"),
|
||||||
.Enum => |info| {
|
.Enum => |info| {
|
||||||
try writer.writeAll(compgenPrefix);
|
try writer.writeAll(compgenPrefix);
|
||||||
for (info.opts, 0..) |f, i| {
|
for (info.opts, 0..) |f, i| {
|
||||||
|
Reference in New Issue
Block a user