forked from nushell/nu_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kw-completions.nu
293 lines (253 loc) · 13.7 KB
/
kw-completions.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
def "nu-complete kw subcommands" [] {
[
[value description];
["init" "Initialize kworkflow config file"]
["build" "Build kernel"]
["deploy" "Deploy a new kernel image to a target machine"]
["bd" "Build and install kernel image/modules"]
["diff" "Diff files"]
["ssh" "SSH support"]
["codestyle" "Apply checkpatch on directory or file"]
["self-update" "kw self-update mechanism"]
["maintainers" "Get maintainers and mailing list"]
["kernel-config-manager" "Manage kernel .config files"]
["config" "Set kw config options"]
["remote" "Manage machines available via ssh"]
["explore" "Explore string patterns"]
["pomodoro" "kw pomodoro support"]
["report" "Show kw pomodoro reports and kw usage statistics"]
["device" "Show basic hardware information"]
["backup" "Save or restore kw data"]
["debug" "Linux kernel debug utilities"]
["mail" "Send patches via email"]
["env" "Handle kw envs"]
["patch-hub" "Interface to lore kernel"]
["clear-cache" "Clear files generated by kw"]
["drm" "Set of commands to work with DRM drivers"]
["vm" "Basic support for QEMU image"]
["version" "Show kw version"]
["man" "Show manual pages"]
["h" "Displays this help message"]
["help" "Show kw man page"]
]
}
def "nu-complete kw man pages" [] {
nu-complete kw subcommands | where value != "bd" and value != "h" and value != "help" and value != "man"
}
def "nu-complete kw warnings" [] {
[
[value description];
["1" "not too often, may be relevant"]
["2" "quite often, may still be relevant"]
["3" "more obscure, likely ignorable"]
["12" "warns 1 and 2"]
["13" "warns 1 and 3"]
["23" "warns 2 and 3"]
["123" "all warnings"]
]
}
def "nu-complete kw target" [] {
["local", "remote"]
}
def "nu-complete kw init template" [] {
["x86-64", "rpi4-raspbian-32-cross-x86-arm", "rpi4-raspbian-64-cross-x86-arm"]
}
def "nu-complete kw init arch" [] {
if ("arch" | path exists) {
ls arch
| where type == "dir"
| get name
| each {|el| $el | str replace 'arch/' ''}
} else {
[]
}
}
def "nu-complete kw deploy alert" [] {
["s", "v", "sv", "vs", "n"]
}
def "nu-complete kw cores" [] {
1..(sys cpu | length)
}
def "nu-complete kw configs" [] {
^kw config -s
| lines
| parse --regex '\[.*\] (?<value>[a-z_.]+)=(?<description>.+)$'
}
def "nu-complete kw remotes" [] {
^kw remote --list
| lines
| filter {|line| not ($line | str contains " ")}
}
# The inglorious kernel developer workflow tool
export extern "kw" [
subcommand?: string@"nu-complete kw subcommands" # Subcommand to run
--help(-h) # Shows help page
--version(-v) # Shows version
]
# Show kw manual pages
export extern "kw man" [
page?: string@"nu-complete kw man pages" # Manual page to show
]
# Show kw version
export extern "kw version" [
...args: string
]
# Initalize kworkflow config file
export extern "kw init" [
--template: string@"nu-complete kw init template" # Uses a template as the kworkflow.config
--arch: string@"nu-complete kw init arch" # Sets the variable arch from the newly created kworkflow.config
--remote: string # <user>@<host>:<port> set the variables ssh_user, ssh_ip, and ssh_port to <user>, <ip>, and <port>, respectively.
--target: string@"nu-complete kw target" # Sets default_deploy_target from kworkflow.config
--help(-h) # Shows help page
--verbose # Verbose mode
]
# Builds the kernel
export extern "kw build" [
...flags: string
--info(-i) # Displays build information
--menu(-n) # Invokes the kernel menuconfig
--doc(-d) # Builds the documentation
--cpu-scaling(-S): int@"nu-complete kw cores" # Sets the number of jobs to use for building the kernel (the -j flag)
--ccache # Enable ccache
--warnings(-w): string@"nu-complete kw warnings" # Sets the warning level for the kernel build
--save-log-to(-s): string # Saves the build log to a file
--llvm # Uses LLVM toolchain during compilation and linking
--clean(-c) # Removes build files (keeps the configuration)
--full-cleanup(-f) # Runs make distclean to reset the tree to the default state
--cflags # Allow passing of flags to the compiler
--alert: string
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw b" = kw build
# Deploy the kernel
export extern "kw deploy" [
--remote: string, # deploy to a machine in the network
--local # deploy to the host machine
--reboot(-r) # reboot machine after deploy
--no-reboot # do not reboot machine after deploy
--setup # run basic setup in the target machine
--modules(-m) # only install/update modules
--list(-l) # list available kernels in a single column
--list-all(-a) # list all available kernels
--ls-line(-s) # list available kernels separated by comma
--uninstall(-u): string # remove a single or multiple kernels
--force(-f) # remove kernels not installed by kw
--create-package(-p) # create a kw package without deploying
--from-package(-F) # deploy a custom kernel from kw package
--alert: string@"nu-complete kw deploy alert" # set alert behaviour upon command completion
--help(-h) # Shows help page
]
export alias "kw d" = kw deploy
# Useful wrapper to the diff command to compare files or directories
export extern "kw diff" [
...files: string
--no-interactive # Displays all diff in two columns at once
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw df" = kw diff
# Ssh access into any network accessible machine
export extern "kw ssh" [
--command(-c): string # Bash command to run on the remote machine
--script(-s): string # Bash script to run on the remote machine
--remote(-r): string # <user>@<host>:<port> parameters to ssh into the target machine
--send: string # Sends a local file to the remote. Needs to use --to after it
--get: string # Gets a remote file to the local. Needs to use --to after it
--to: string # The destination path. On the remote if --send. On the local if --get
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw s" = kw ssh
export extern "kw codestyle" [
path?: string # Which files to run checkpatch on. Defaults to the cwd
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw c" = kw codestyle
export extern "kw self-update" [
--unstable(-u) # Update kw based on the unstable branch
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw u" = kw self-update
export extern "kw maintainers" [
path?: string # Path to the folder to show the maintainers of
--authors(-a) # Prints (non-recursively) the authors of the top-level target files
--update-patch(-u) # Include a `To:` field in the patch header
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw m" = kw maintainers
export extern "kw kernel-config-manager" [
--save: string # Creates a snapshot of the .config file with the given name
-d: string # Sets the description when using --save
--force(-f) # Supress warnings
--get: string # Gets the config with the given name and overwrites the current .config file
--remove(-r): string # Removes the config with the given name
--list(-l) # Lists all the configs being managed
--fetch # Fetches a .config from a target machine
--output(-o): string # Sets the output file when using --fetch
--optimize # Runs make localmodconfig to procude a config optimized for the target machine when using --fetch
--remove: string # Sets the remote <user>@<host>:<port> when using --fetch
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw k" = kw kernel-config-manager
export extern "kw config" [
option?: string@"nu-complete kw configs" # Config options to set
value?: string # Value to set the option to
--global(-g) # Set the option globally
--local(-l) # Set the option locally
--show(-s) # Show the current configurations for a given target
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw g" = kw config
# Manage set of tracked test machines
export extern "kw remote" [
--global # Force use global config file instead of the local one
--add: string # Adds a remote named <name> for the machine at <remote-address>
--remove: string@"nu-complete kw remotes" # Remove the remote named <name>
--rename: string@"nu-complete kw remotes" # Rename the remote named <old-name> to <new-name>
--list # List all available remotes.
--set-default(-s) # Set the default remote
--verbose(-v) # Verbose mode
]
# Git grep wrapper
export extern "kw explore" [
expr?: string # Expression to search for
--log(-l) # Search using git log with the given string
--grep(-g) # Search using grep with the given string
--all(-a) # Search using git grep with the given string
--only-source(-c) # Show only results from source code
--only-header(-H) # Show only results from header
-p: string # Path to where to start the search
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw e" = kw explore
export extern "kw pomodoro" [
--set-timer(-t): string # Define a timer for the pomodoro (h | m | s)
--tag(-g): string # Tag the pomodoro
--description(-d): string # Describe the pomodoro task
--check-timer(-c) # Check the current timer
--show-tags(-s) # Show all tags used in pomodoros
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw p" = kw pomodoro
# User data report support
export extern "kw report" [
--year: string="" # Shows the report for the current year if not specified <year>
--month: string="" # Shows the report for the current month if not specified <year>/<month>
--week: string="" # Shows the report for the current week if not specified <year>/<week>
--day: string="" # Shows the report for the current day if not specified <year>/<month>/<day>
--all # Shows all the data in the report
--statistics(-s) # Shows the statistics of the report
--pomodoro # Shows the pomodoro data in the report
--output: string # Output the report to a file
--help(-h) # Shows help page
--verbose # Verbose mode
]
export alias "kw r" = kw report