mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
cli: move cli_args.zig to cli
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
pub const args = @import("cli/args.zig");
|
||||||
pub const Action = @import("cli/action.zig").Action;
|
pub const Action = @import("cli/action.zig").Action;
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@ -4,7 +4,7 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = mem.Allocator;
|
const Allocator = mem.Allocator;
|
||||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||||
|
|
||||||
const ErrorList = @import("config/ErrorList.zig");
|
const ErrorList = @import("../config/ErrorList.zig");
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - Only `--long=value` format is accepted. Do we want to allow
|
// - Only `--long=value` format is accepted. Do we want to allow
|
@ -1,5 +1,5 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const cli_args = @import("../cli_args.zig");
|
const cli = @import("../cli.zig");
|
||||||
const inputpkg = @import("../input.zig");
|
const inputpkg = @import("../input.zig");
|
||||||
const global = &@import("../main.zig").state;
|
const global = &@import("../main.zig").state;
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ export fn ghostty_config_load_string(
|
|||||||
|
|
||||||
fn config_load_string_(self: *Config, str: []const u8) !void {
|
fn config_load_string_(self: *Config, str: []const u8) !void {
|
||||||
var fbs = std.io.fixedBufferStream(str);
|
var fbs = std.io.fixedBufferStream(str);
|
||||||
var iter = cli_args.lineIterator(fbs.reader());
|
var iter = cli.args.lineIterator(fbs.reader());
|
||||||
try cli_args.parse(Config, global.alloc, self, &iter);
|
try cli.args.parse(Config, global.alloc, self, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load the configuration from the default file locations. This
|
/// Load the configuration from the default file locations. This
|
||||||
|
@ -10,7 +10,7 @@ const fontpkg = @import("../font/main.zig");
|
|||||||
const inputpkg = @import("../input.zig");
|
const inputpkg = @import("../input.zig");
|
||||||
const terminal = @import("../terminal/main.zig");
|
const terminal = @import("../terminal/main.zig");
|
||||||
const internal_os = @import("../os/main.zig");
|
const internal_os = @import("../os/main.zig");
|
||||||
const cli_args = @import("../cli_args.zig");
|
const cli = @import("../cli.zig");
|
||||||
|
|
||||||
const Key = @import("key.zig").Key;
|
const Key = @import("key.zig").Key;
|
||||||
const KeyValue = @import("key.zig").Value;
|
const KeyValue = @import("key.zig").Value;
|
||||||
@ -765,8 +765,8 @@ pub fn loadDefaultFiles(self: *Config, alloc: Allocator) !void {
|
|||||||
std.log.info("reading configuration file path={s}", .{home_config_path});
|
std.log.info("reading configuration file path={s}", .{home_config_path});
|
||||||
|
|
||||||
var buf_reader = std.io.bufferedReader(file.reader());
|
var buf_reader = std.io.bufferedReader(file.reader());
|
||||||
var iter = cli_args.lineIterator(buf_reader.reader());
|
var iter = cli.args.lineIterator(buf_reader.reader());
|
||||||
try cli_args.parse(Config, alloc, self, &iter);
|
try cli.args.parse(Config, alloc, self, &iter);
|
||||||
} else |err| switch (err) {
|
} else |err| switch (err) {
|
||||||
error.FileNotFound => std.log.info(
|
error.FileNotFound => std.log.info(
|
||||||
"homedir config not found, not loading path={s}",
|
"homedir config not found, not loading path={s}",
|
||||||
@ -792,7 +792,7 @@ pub fn loadCliArgs(self: *Config, alloc_gpa: Allocator) !void {
|
|||||||
// Parse the config from the CLI args
|
// Parse the config from the CLI args
|
||||||
var iter = try std.process.argsWithAllocator(alloc_gpa);
|
var iter = try std.process.argsWithAllocator(alloc_gpa);
|
||||||
defer iter.deinit();
|
defer iter.deinit();
|
||||||
try cli_args.parse(Config, alloc_gpa, self, &iter);
|
try cli.args.parse(Config, alloc_gpa, self, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load and parse the config files that were added in the "config-file" key.
|
/// Load and parse the config files that were added in the "config-file" key.
|
||||||
@ -819,8 +819,8 @@ pub fn loadRecursiveFiles(self: *Config, alloc: Allocator) !void {
|
|||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
var buf_reader = std.io.bufferedReader(file.reader());
|
var buf_reader = std.io.bufferedReader(file.reader());
|
||||||
var iter = cli_args.lineIterator(buf_reader.reader());
|
var iter = cli.args.lineIterator(buf_reader.reader());
|
||||||
try cli_args.parse(Config, alloc, self, &iter);
|
try cli.args.parse(Config, alloc, self, &iter);
|
||||||
|
|
||||||
// We don't currently support adding more config files to load
|
// We don't currently support adding more config files to load
|
||||||
// from within a loaded config file. This can be supported
|
// from within a loaded config file. This can be supported
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const wasm = @import("../os/wasm.zig");
|
const wasm = @import("../os/wasm.zig");
|
||||||
const cli_args = @import("../cli_args.zig");
|
const cli = @import("../cli.zig");
|
||||||
const alloc = wasm.alloc;
|
const alloc = wasm.alloc;
|
||||||
|
|
||||||
const Config = @import("Config.zig");
|
const Config = @import("Config.zig");
|
||||||
@ -43,8 +43,8 @@ export fn config_load_string(
|
|||||||
|
|
||||||
fn config_load_string_(self: *Config, str: []const u8) !void {
|
fn config_load_string_(self: *Config, str: []const u8) !void {
|
||||||
var fbs = std.io.fixedBufferStream(str);
|
var fbs = std.io.fixedBufferStream(str);
|
||||||
var iter = cli_args.lineIterator(fbs.reader());
|
var iter = cli.args.lineIterator(fbs.reader());
|
||||||
try cli_args.parse(Config, alloc, self, &iter);
|
try cli.args.parse(Config, alloc, self, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn config_finalize(self: *Config) void {
|
export fn config_finalize(self: *Config) void {
|
||||||
|
@ -300,6 +300,5 @@ test {
|
|||||||
// TODO
|
// TODO
|
||||||
_ = @import("blocking_queue.zig");
|
_ = @import("blocking_queue.zig");
|
||||||
_ = @import("config.zig");
|
_ = @import("config.zig");
|
||||||
_ = @import("cli_args.zig");
|
|
||||||
_ = @import("lru.zig");
|
_ = @import("lru.zig");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user