summaryrefslogtreecommitdiff
path: root/src/cli/args.zig
AgeCommit message (Collapse)Author
2025-10-03Zig 0.15: zig build test Mitchell Hashimoto
2025-10-03Zig 0.15: zig fmtMitchell Hashimoto
2025-09-29config: modify MouseScrollMultiplier to lean on args parsingMitchell Hashimoto
2025-09-23rename Splitter-CommaSplitterJeffrey C. Ollie
2025-09-23config: smarter parsing in autoParseStructJeffrey C. Ollie
Fixes #8849 Previously, the `parseAutoStruct` function that was used to parse generic structs for the config simply split the input value on commas without taking into account quoting or escapes. This led to problems because it was impossible to include a comma in the value of config entries that were parsed by `parseAutoStruct`. This is particularly problematic because `ghostty +show-config --default` would produce output like the following: ``` command-palette-entry = title:Focus Split: Next,description:Focus the next split, if any.,action:goto_split:next ``` Because the `description` contains a comma, Ghostty is unable to parse this correctly. The value would be split into four parts: ``` title:Focus Split: Next description:Focus the next split if any. action:goto_split:next ``` Instead of three parts: ``` title:Focus Split: Next description:Focus the next split, if any. action:goto_split:next ``` Because `parseAutoStruct` simply looked for commas to split on, no amount of quoting or escaping would allow that to be parsed correctly. This is fixed by (1) introducing a parser that will split the input to `parseAutoStruct` into fields while taking into account quotes and escaping. And (2) changing the `ghostty +show-config` output to put the values in `command-palette-entry` into quotes so that Ghostty can parse it's own output. `parseAutoStruct` will also now parse double quoted values as a Zig string literal. This makes it easier to embed control codes, whitespace, and commas in values.
2025-09-05gtk-ng: deprecate detection of launch sourceJeffrey C. Ollie
Detecting the launch source frequently failed because various launchers fail to sanitize the environment variables that Ghostty used to detect the launch source. For example, if your desktop environment was launched by `systemd`, but your desktop environment did not sanitize the `INVOCATION_ID` or the `JOURNAL_STREAM` environment variables, Ghostty would assume that it had been launched by `systemd` and behave as such. This led to complaints about Ghostty not creating new windows when users expected that it would. To remedy this, Ghostty no longer does any detection of the launch source. If your launch source is something other than the CLI, it must be explicitly speciflied on the CLI. All of Ghostty's default desktop and service files do this. Users or packagers that create custom desktop or service files will need to take this into account. On GTK, the `desktop` setting for `gtk-single-instance` is replaced with `detect`. `detect` behaves as `gtk-single-instance=true` if one of the following conditions is true: 1. If no CLI arguments have been set. 2. If `--launched-from` has been set to `desktop`, `dbus`, or `systemd`. Otherwise `detect` behaves as `gtk-single-instance=false`.
2025-07-14cli/gtk: remove --release and --debug flags, use optional for argumentsJeffrey C. Ollie
2025-06-28config: fix regression where we halted parsing on deprecated fieldMitchell Hashimoto
Fix regression from d44a6cde2c7ed59f0f28fad16e6b760d7529ebee where we halted parsing on deprecated fields, which was not the intended behavior. This commit fixes that and adds a test to verify it.
2025-06-28config: more general purpose backwards compatibility handlersMitchell Hashimoto
Fixes #7706 We previously had a very specific backwards compatibility handler for handling renamed fields. We always knew that wouldn't scale but I wanted to wait for a real case. Well, #7706 is a real case, so here we are. This commit makes our backwards compatibility handler more general purpose, and makes a special-case handler for renamed fields built on top of this same general purpose system. The new system lets us do a lot more with regards to backwards compatibility. To start, this addresses #7706 by allowing us to handle a removed single enum value of a still-existing field.
2025-06-22`input` configuration to pass input as stdin on startupMitchell Hashimoto
This adds a new configuration `input` that allows passing either raw text or file contents as stdin when starting the terminal. The input is sent byte-for-byte to the terminal, so control characters such as `\n` will be interpreted by the shell and can be used to run programs in the context of the loaded shell. Example: `ghostty --input="hello, world\n"` will start the your default shell, run `echo hello, world`, and then show the prompt.
2025-05-26style: use decl literalsQwerasd
This commit changes a LOT of areas of the code to use decl literals instead of redundantly referring to the type. These changes were mostly driven by some regex searches and then manual adjustment on a case-by-case basis. I almost certainly missed quite a few places where decl literals could be used, but this is a good first step in converting things, and other instances can be addressed when they're discovered. I tested GLFW+Metal and building the framework on macOS and tested a GTK build on Linux, so I'm 99% sure I didn't introduce any syntax errors or other problems with this. (fingers crossed)
2025-03-12Lots of 0.14 changesMitchell Hashimoto
2025-02-25fix testDavid Mo
2025-02-25rename `setToDefault` to `init`David Mo
2025-02-24add test for `setToDefault`David Mo
2025-02-24set default keybinds when parsing empty keybind configDavid Mo
2025-02-08core: protect against crashes and hangs when themes are not filesJeffrey C. Ollie
If a theme was not a file or a directory you could get a crash or a hang (depending on platform) if the theme references a directory. This patch also prevents attempts to load from other non-file sources. Fixes: #5596
2025-01-23cli: allow renaming config fields to maintain backwards compatibilityMitchell Hashimoto
Fixes #4631 This introduces a mechanism by which parsed config fields can be renamed to maintain backwards compatibility. This already has a use case -- implemented in this commit -- for `background-blur-radius` to be renamed to `background-blur`. The remapping is comptime-known which lets us do some comptime validation. The remap check isn't done unless no fields match which means for well-formed config files, there's no overhead. For future improvements: - We should update our config help generator to note renamed fields. - We could offer automatic migration of config files be rewriting them. - We can enrich the value type with more metadata to help with config gen or other tooling.
2025-01-05config: allow booleans for `background-blur-radius`Leah Amelia Chen
2024-12-17core: allow u21 as a cli argument typeJeffrey C. Ollie
2024-12-17core: allow cli actions to use arg parsing diagnosticsJeffrey C. Ollie
2024-11-27config: need to dupe filepath for diagnosticsMitchell Hashimoto
Fixes #2800 The source string with the filepath is not guaranteed to exist beyond the lifetime of the parse operation. We must copy it.
2024-11-20cli: parseCLI for optionals should not be null in release modesMitchell Hashimoto
Fixes #2747 I admit I don't fully understand this. But somehow, doing `var x: ?T = undefined` in release fast mode makes `x` act as if its unset. I am guessing since undefined does nothing to the memory, the memory layout is such that it looks null for zeroed stack memory. This is a guess. To fix this, I now initialize the type `T` and set it onto the optional later. This commit also fixes an issue where calling `parseCLI` multiple times on an optional would not modify the previous value if set.
2024-11-19cli: parseCLI form works with optionalsMitchell Hashimoto
2024-11-19cli: parse auto structsMitchell Hashimoto
2024-11-09core: address review commentsJeffrey C. Ollie
- break formatting values out into a function so that we can catch errors and never fail - eliminate the use of toOwnedSentinelSlice since we are using an arena to clean up memory
2024-11-08core: list valid options if an invalid value is detected parsing an enumJeffrey C. Ollie
2024-10-18cli: skip argv0 and actions when parsing CLI flagsMitchell Hashimoto
This fixes a regression from #2454. In that PR, we added an error when positional arguments are detected. I believe that's correct, but we were silently relying on the previous behavior in the CLI commands. This commit changes the CLI commands to use a new argsIterator function that creates an iterator that skips the first argument (argv0). This is the same behavior that the config parsing does and now uses this shared logic. This also makes it so the argsIterator ignores actions (`+things`) and we document that we expect those to be handled earlier.
2024-10-18cli: positional arguments are invalid when parsing configurationMitchell Hashimoto
2024-10-18c: remove the config load string APIMitchell Hashimoto
It was unused and doesn't match our diagnostic API.
2024-10-18config: track the location of CLI argument errorsMitchell Hashimoto
2024-10-18config: show filepath and line numbers for config errorsMitchell Hashimoto
Fixes #1063
2024-10-18config: richer diagnostics for errorsMitchell Hashimoto
Rather than storing a list of errors we now store a list of "diagnostics." Each diagnostic has a richer set of structured information, including a message, a key, the location where it occurred. This lets us show more detailed messages, more human friendly messages, and also let's us filter by key or location. We don't take advantage of all of this capability in this initial commit, but we do use every field for something.
2024-09-16cli: config structure supports tagged unionsMitchell Hashimoto
The syntax of tagged unions is `tag:value`. This matches the tagged union parsing syntax for keybindings (i.e. `new_split:right`). I'm adding this now on its own without a user-facing feature because I can see some places we might use this and I want to separate this out. There is already a PR open now that can utilize this (#2231).
2024-07-09cli: boolean value support for packed structsJon Parise
Allow standalone boolean values like "true" and "false" to turn on or off all of the struct's fields.
2024-05-09feat(font): Non-integer point sizesQwerasd
Allows for high dpi displays to get odd numbered pixel sizes, for example, 13.5pt @ 2px/pt for 27px font. This implementation performs all the sizing calculations with f32, rounding to the nearest pixel size when it comes to rendering. In the future this can be enhanced by adding fractional scaling to support fractional pixel sizes.
2024-03-22cli: arg parsing supports more int typesMitchell Hashimoto
2024-03-13update zigMitchell Hashimoto
2024-01-23config: re-expand relative paths correctly when reloading configMitchell Hashimoto
Fixes #1366 When we use `loadTheme`, we "replay" the configuration so that the theme is the base configuration and everything else can override everything the theme sets. During this process, we were not properly re-expanding all the relative paths. This fix works by changing our input tracking from solely tracking args to tracking operations such as expansion as well. When we "replay" the configuration we also replay operations such as path expansion with the correct base path. This also removes the `_inputs` special mechanism `cli/args.zig` had because we can already do that ourselves using `parseManuallyHook`.
2024-01-23empty cli or config args reset the value to the defaultMitchell Hashimoto
Fixes #1367 We previously special-cased optionals but we should do better and have this reset ANY type to the defined default value on the struct.
2024-01-20cli: empty field resets optionals to nullMitchell Hashimoto
2024-01-20cli: support --help and -h for actionsMitchell Hashimoto
2024-01-05cli: strip CR in line iteratorGregory Anders
2023-12-30Make the abnormal runtime threshold configurable.Jeffrey C. Ollie
2023-11-30Update to latest master,Krzysztof Wolicki
update libxev dependency, change mach_glfw to an updated fork until upstream updates
2023-11-22config: add "theme" config, track inputsMitchell Hashimoto
2023-11-07config: packed struct of bools supported as config fieldMitchell Hashimoto
2023-10-27cli: handle "-e" as the command to executeMitchell Hashimoto
2023-10-02update zigMitchell Hashimoto
2023-09-26cli: args can parse unionsMitchell Hashimoto