From 7b7661ce0cd5178816cf62f5f36f7d2c477851ac Mon Sep 17 00:00:00 2001 From: Andy Carlson <2yinyang2@gmail.com> Date: Fri, 13 Feb 2026 12:11:43 +0100 Subject: [PATCH] implement timedatectl completions --- command-signatures/json/timedatectl.json | 186 ++++++++++++++++++ command-signatures/src/generators/mod.rs | 2 + .../src/generators/timedatectl.rs | 19 ++ 3 files changed, 207 insertions(+) create mode 100644 command-signatures/json/timedatectl.json create mode 100644 command-signatures/src/generators/timedatectl.rs diff --git a/command-signatures/json/timedatectl.json b/command-signatures/json/timedatectl.json new file mode 100644 index 00000000..1af838d1 --- /dev/null +++ b/command-signatures/json/timedatectl.json @@ -0,0 +1,186 @@ +{ + "name": "timedatectl", + "description": "Query or change system time and date settings", + "subcommands": [ + { + "name": "status", + "description": "Show current time settings" + }, + { + "name": "show", + "description": "Show properties of systemd-timedated", + "options": [ + { + "name": ["-p", "--property"], + "description": "Show only properties by this name", + "args": { + "name": "name", + "description": "Property name" + } + }, + { + "name": ["-a", "--all"], + "description": "Show all properties, including empty ones" + }, + { + "name": "--value", + "description": "When showing properties, only print the value" + } + ] + }, + { + "name": "set-time", + "description": "Set system time", + "args": { + "name": "time", + "description": "Time to set (YYYY-MM-DD HH:MM:SS)" + } + }, + { + "name": "set-timezone", + "description": "Set system time zone", + "args": { + "name": "zone", + "description": "Time zone to set", + "generatorName": "list_timezones" + } + }, + { + "name": "list-timezones", + "description": "Show known time zones" + }, + { + "name": "set-local-rtc", + "description": "Control whether RTC is in local time", + "args": { + "name": "bool", + "description": "Whether RTC is in local time", + "suggestions": ["true", "false"] + } + }, + { + "name": "set-ntp", + "description": "Enable or disable network time synchronization", + "args": { + "name": "bool", + "description": "Whether to enable NTP", + "suggestions": ["true", "false"] + } + }, + { + "name": "timesync-status", + "description": "Show status of systemd-timesyncd" + }, + { + "name": "show-timesync", + "description": "Show properties of systemd-timesyncd", + "options": [ + { + "name": ["-p", "--property"], + "description": "Show only properties by this name", + "args": { + "name": "name", + "description": "Property name" + } + }, + { + "name": ["-a", "--all"], + "description": "Show all properties, including empty ones" + }, + { + "name": "--value", + "description": "When showing properties, only print the value" + } + ] + }, + { + "name": "ntp-servers", + "description": "Set the interface specific NTP servers", + "args": [ + { + "name": "interface", + "description": "Network interface" + }, + { + "name": "server", + "description": "NTP server(s)", + "isVariadic": true + } + ] + }, + { + "name": "revert", + "description": "Revert the interface specific NTP servers", + "args": { + "name": "interface", + "description": "Network interface" + } + } + ], + "options": [ + { + "name": ["-h", "--help"], + "description": "Show this help message" + }, + { + "name": "--version", + "description": "Show package version" + }, + { + "name": "--no-pager", + "description": "Do not pipe output into a pager" + }, + { + "name": "--no-ask-password", + "description": "Do not prompt for password" + }, + { + "name": ["-H", "--host"], + "description": "Operate on remote host", + "args": { + "name": "host", + "description": "[USER@]HOST" + } + }, + { + "name": ["-M", "--machine"], + "description": "Operate on local container", + "args": { + "name": "container", + "description": "Container name" + } + }, + { + "name": "--adjust-system-clock", + "description": "Adjust system clock when changing local RTC mode" + }, + { + "name": "--monitor", + "description": "Monitor status of systemd-timesyncd" + }, + { + "name": ["-p", "--property"], + "description": "Show only properties by this name", + "args": { + "name": "name", + "description": "Property name" + } + }, + { + "name": ["-a", "--all"], + "description": "Show all properties, including empty ones" + }, + { + "name": "--value", + "description": "When showing properties, only print the value" + }, + { + "name": "-P", + "description": "Equivalent to --value --property=NAME", + "args": { + "name": "name", + "description": "Property name" + } + } + ] +} diff --git a/command-signatures/src/generators/mod.rs b/command-signatures/src/generators/mod.rs index 15424bb5..49f717d9 100644 --- a/command-signatures/src/generators/mod.rs +++ b/command-signatures/src/generators/mod.rs @@ -41,6 +41,7 @@ mod screen; mod ssh; mod tar; mod terraform; +mod timedatectl; mod tmux; mod tmuxinator; @@ -86,6 +87,7 @@ pub fn dynamic_command_signature_data() -> HashMap CommandSignatureGenerators { + CommandSignatureGenerators::new("timedatectl").add_generator( + "list_timezones", + Generator::script( + CommandBuilder::single_command("timedatectl list-timezones"), + |output| { + output + .lines() + .filter(|line| !line.is_empty()) + .map(|tz| Suggestion::new(tz.to_string())) + .collect_unordered_results() + }, + ), + ) +}