Skip to content

Commit 70cf5dc

Browse files
acarl005oz-agent
andcommitted
Add completion spec for timedatectl
Add JSON spec with subcommands (status, show, set-time, set-timezone, list-timezones, set-local-rtc, set-ntp, timesync-status, show-timesync) and global options. Includes a timezone_generator for dynamic timezone completions via timedatectl list-timezones. Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent c059425 commit 70cf5dc

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"name": "timedatectl",
3+
"description": "Control the system time and date",
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+
}
19+
},
20+
{
21+
"name": "set-timezone",
22+
"description": "Set system time zone",
23+
"args": {
24+
"name": "TIMEZONE",
25+
"generatorName": "timezone_generator"
26+
}
27+
},
28+
{
29+
"name": "list-timezones",
30+
"description": "Show known time zones"
31+
},
32+
{
33+
"name": "set-local-rtc",
34+
"description": "Control whether RTC is in local time",
35+
"args": {
36+
"name": "BOOL",
37+
"suggestions": [
38+
"true",
39+
"false"
40+
]
41+
}
42+
},
43+
{
44+
"name": "set-ntp",
45+
"description": "Control network time sync",
46+
"args": {
47+
"name": "BOOL",
48+
"suggestions": [
49+
"true",
50+
"false"
51+
]
52+
}
53+
},
54+
{
55+
"name": "timesync-status",
56+
"description": "Show status of systemd-timesyncd"
57+
},
58+
{
59+
"name": "show-timesync",
60+
"description": "Show properties of systemd-timesyncd"
61+
}
62+
],
63+
"options": [
64+
{
65+
"name": [
66+
"-h",
67+
"--help"
68+
],
69+
"description": "Show this help message"
70+
},
71+
{
72+
"name": "--version",
73+
"description": "Show package version"
74+
},
75+
{
76+
"name": "--no-pager",
77+
"description": "Do not pipe output into a pager"
78+
},
79+
{
80+
"name": "--no-ask-password",
81+
"description": "Do not prompt for password"
82+
},
83+
{
84+
"name": [
85+
"-H",
86+
"--host"
87+
],
88+
"description": "Operate on remote HOST",
89+
"args": {
90+
"name": "HOST"
91+
}
92+
},
93+
{
94+
"name": [
95+
"-M",
96+
"--machine"
97+
],
98+
"description": "Operate on local CONTAINER",
99+
"args": {
100+
"name": "CONTAINER"
101+
}
102+
},
103+
{
104+
"name": "--adjust-system-clock",
105+
"description": "Adjust system clock when changing local RTC mode"
106+
},
107+
{
108+
"name": "--monitor",
109+
"description": "Monitor status of systemd-timesyncd"
110+
},
111+
{
112+
"name": [
113+
"-p",
114+
"--property"
115+
],
116+
"description": "Show only properties by this NAME",
117+
"args": {
118+
"name": "NAME"
119+
}
120+
},
121+
{
122+
"name": [
123+
"-a",
124+
"--all"
125+
],
126+
"description": "Show all properties"
127+
},
128+
{
129+
"name": "--value",
130+
"description": "Only show properties with values"
131+
}
132+
]
133+
}

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+
"timezone_generator",
8+
Generator::script(
9+
CommandBuilder::single_command("timedatectl list-timezones"),
10+
|output| {
11+
output
12+
.trim()
13+
.lines()
14+
.map(|line| Suggestion::new(line.trim()))
15+
.collect_unordered_results()
16+
},
17+
),
18+
)
19+
}

0 commit comments

Comments
 (0)