Skip to content

Commit f4d7ba9

Browse files
acarl005oz-agent
andcommitted
Add completion spec: timedatectl
Add command completion spec for timedatectl with: - All subcommands: status, show, set-time, set-timezone, list-timezones, set-local-rtc, set-ntp, timesync-status, show-timesync, ntp-servers, revert - All options from --help including -H/--host, -M/--machine, -p/--property, etc. - Timezone generator for set-timezone using timedatectl list-timezones - Boolean suggestions for set-local-rtc and set-ntp Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent 13ab1e7 commit f4d7ba9

3 files changed

Lines changed: 175 additions & 0 deletions

File tree

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"name": "timedatectl",
3+
"description": "Query or change system time and date settings",
4+
"subcommands": [
5+
{
6+
"name": "status",
7+
"description": "Show current time settings"
8+
},
9+
{
10+
"name": "show",
11+
"description": "Show properties of systemd-timedated"
12+
},
13+
{
14+
"name": "set-time",
15+
"description": "Set system time",
16+
"args": {
17+
"name": "TIME",
18+
"description": "Time to set (format: \"YYYY-MM-DD HH:MM:SS\")"
19+
}
20+
},
21+
{
22+
"name": "set-timezone",
23+
"description": "Set system time zone",
24+
"args": {
25+
"name": "ZONE",
26+
"generatorName": "timezones"
27+
}
28+
},
29+
{
30+
"name": "list-timezones",
31+
"description": "Show known time zones"
32+
},
33+
{
34+
"name": "set-local-rtc",
35+
"description": "Control whether RTC is in local time",
36+
"args": {
37+
"name": "BOOL",
38+
"suggestions": [
39+
"true",
40+
"false"
41+
]
42+
}
43+
},
44+
{
45+
"name": "set-ntp",
46+
"description": "Enable or disable network time synchronization",
47+
"args": {
48+
"name": "BOOL",
49+
"suggestions": [
50+
"true",
51+
"false"
52+
]
53+
}
54+
},
55+
{
56+
"name": "timesync-status",
57+
"description": "Show status of systemd-timesyncd"
58+
},
59+
{
60+
"name": "show-timesync",
61+
"description": "Show properties of systemd-timesyncd"
62+
},
63+
{
64+
"name": "ntp-servers",
65+
"description": "Set the interface specific NTP servers",
66+
"args": [
67+
{
68+
"name": "INTERFACE"
69+
},
70+
{
71+
"name": "SERVER",
72+
"isVariadic": true
73+
}
74+
]
75+
},
76+
{
77+
"name": "revert",
78+
"description": "Revert the interface specific NTP server settings",
79+
"args": {
80+
"name": "INTERFACE"
81+
}
82+
}
83+
],
84+
"options": [
85+
{
86+
"name": [
87+
"-h",
88+
"--help"
89+
],
90+
"description": "Show this help message"
91+
},
92+
{
93+
"name": "--version",
94+
"description": "Show package version"
95+
},
96+
{
97+
"name": "--no-pager",
98+
"description": "Do not pipe output into a pager"
99+
},
100+
{
101+
"name": "--no-ask-password",
102+
"description": "Do not prompt for password"
103+
},
104+
{
105+
"name": [
106+
"-H",
107+
"--host"
108+
],
109+
"description": "Operate on remote host",
110+
"args": {
111+
"name": "HOST"
112+
}
113+
},
114+
{
115+
"name": [
116+
"-M",
117+
"--machine"
118+
],
119+
"description": "Operate on local container",
120+
"args": {
121+
"name": "CONTAINER"
122+
}
123+
},
124+
{
125+
"name": "--adjust-system-clock",
126+
"description": "Adjust system clock when changing local RTC mode"
127+
},
128+
{
129+
"name": "--monitor",
130+
"description": "Monitor status of systemd-timesyncd"
131+
},
132+
{
133+
"name": [
134+
"-p",
135+
"--property"
136+
],
137+
"description": "Show only properties by this name",
138+
"args": {
139+
"name": "NAME"
140+
}
141+
},
142+
{
143+
"name": [
144+
"-a",
145+
"--all"
146+
],
147+
"description": "Show all properties, including empty ones"
148+
},
149+
{
150+
"name": "--value",
151+
"description": "When showing properties, only print the value"
152+
}
153+
]
154+
}

command-signatures/src/generators/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mod screen;
4141
mod ssh;
4242
mod tar;
4343
mod terraform;
44+
mod timedatectl;
4445
mod tmux;
4546
mod tmuxinator;
4647

@@ -86,6 +87,7 @@ pub fn dynamic_command_signature_data() -> HashMap<String, DynamicCompletionData
8687
kubecolor::generator(),
8788
kill::generator(),
8889
killall::generator(),
90+
timedatectl::generator(),
8991
tmuxinator::generator(),
9092
tmux::generator(),
9193
node::generator(),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use warp_completion_metadata::{
2+
CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion,
3+
};
4+
5+
pub fn generator() -> CommandSignatureGenerators {
6+
CommandSignatureGenerators::new("timedatectl").add_generator(
7+
"timezones",
8+
Generator::script(
9+
CommandBuilder::single_command("timedatectl list-timezones"),
10+
|output| {
11+
output
12+
.lines()
13+
.filter(|line| !line.is_empty())
14+
.map(|line| Suggestion::new(line.trim()))
15+
.collect_unordered_results()
16+
},
17+
),
18+
)
19+
}

0 commit comments

Comments
 (0)