forked from nushell/nu_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kw-completions.nu
209 lines (180 loc) · 9.28 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
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)
}
# 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
]
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
--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
--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
--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
--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
--verbose # Verbose mode
]
export alias "kw k" = kw kernel-config-manager