-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrex-completion.bash
More file actions
181 lines (171 loc) · 6.96 KB
/
drex-completion.bash
File metadata and controls
181 lines (171 loc) · 6.96 KB
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
#!/bin/bash
# Bash completion for drex command
_drex_completion() {
local cur prev words cword
_init_completion || return
# Top-level commands
local top_commands="studio dataset robot wandb --help -h help"
# Studio subcommands
local studio_commands="start"
# Dataset subcommands
local dataset_commands="stats"
# Robot subcommands
local robot_commands="run"
# Wandb subcommands
local wandb_commands="download"
# Common options
local common_options="--help -h"
local wandb_options="--base-dir"
local robot_run_options="--robot-port --robot-id --screwdriver-camera --side-camera --top-camera --camera-width --camera-height --camera-fps --duration --fps --device --screwdriver-current-limit --clutch-ratio --clutch-cooldown-s --base-dir"
case $cword in
1)
# First argument: top-level commands
COMPREPLY=($(compgen -W "$top_commands" -- "$cur"))
;;
2)
# Second argument: depends on first
case $prev in
studio)
COMPREPLY=($(compgen -W "$studio_commands" -- "$cur"))
;;
dataset)
COMPREPLY=($(compgen -W "$dataset_commands" -- "$cur"))
;;
robot)
COMPREPLY=($(compgen -W "$robot_commands" -- "$cur"))
;;
wandb)
COMPREPLY=($(compgen -W "$wandb_commands" -- "$cur"))
;;
*)
COMPREPLY=()
;;
esac
;;
3)
# Third argument: depends on first command
local command="${words[1]}"
local subcommand="${words[2]}"
if [[ "$command" == "studio" ]]; then
# Studio subcommand handling
case $subcommand in
start)
COMPREPLY=($(compgen -W "--port $common_options" -- "$cur"))
;;
*)
COMPREPLY=()
;;
esac
elif [[ "$command" == "dataset" ]]; then
# Dataset subcommand handling
case $subcommand in
stats)
# First positional argument is the repo_id
# No specific completion for repo IDs
COMPREPLY=($(compgen -W "$common_options" -- "$cur"))
;;
*)
COMPREPLY=()
;;
esac
elif [[ "$command" == "robot" ]]; then
# Robot subcommand handling
case $subcommand in
run)
# First positional argument is required wandb_weights_path, no completion for that
COMPREPLY=($(compgen -W "$robot_run_options $common_options" -- "$cur"))
;;
*)
COMPREPLY=()
;;
esac
elif [[ "$command" == "wandb" ]]; then
# Wandb subcommand handling
case $subcommand in
download)
# First positional argument is required artifact_name, no completion for that
COMPREPLY=($(compgen -W "$wandb_options $common_options" -- "$cur"))
;;
*)
COMPREPLY=()
;;
esac
fi
;;
*)
# Fourth argument and beyond: options based on subcommand
local subcommand="${words[2]}"
case $subcommand in
download)
case $prev in
--base-dir)
# Directory completion for base directory
COMPREPLY=($(compgen -d -- "$cur"))
;;
*)
COMPREPLY=($(compgen -W "$wandb_options $common_options" -- "$cur"))
;;
esac
;;
run)
# Handle robot run command options
case $prev in
--robot-port|--screwdriver-camera|--side-camera|--top-camera)
# Device file completion
COMPREPLY=($(compgen -f -X '!*/dev/video*' -- "$cur") $(compgen -f -X '!*/dev/servo*' -- "$cur"))
;;
--device)
# Device options
COMPREPLY=($(compgen -W "cuda cpu" -- "$cur"))
;;
--camera-width)
# Common widths
COMPREPLY=($(compgen -W "640 800 1024 1280 1920" -- "$cur"))
;;
--camera-height)
# Common heights
COMPREPLY=($(compgen -W "480 600 768 720 1080" -- "$cur"))
;;
--camera-fps|--fps)
# Common FPS values
COMPREPLY=($(compgen -W "15 20 24 25 30 60" -- "$cur"))
;;
--duration)
# Common durations
COMPREPLY=($(compgen -W "30 60 120 180 300" -- "$cur"))
;;
--screwdriver-current-limit)
# Common current limits
COMPREPLY=($(compgen -W "200 250 300 350 400" -- "$cur"))
;;
--clutch-ratio)
# Common clutch ratios
COMPREPLY=($(compgen -W "0.3 0.4 0.5 0.6 0.7" -- "$cur"))
;;
--clutch-cooldown-s)
# Common cooldown values
COMPREPLY=($(compgen -W "0.5 1.0 1.5 2.0" -- "$cur"))
;;
--base-dir)
# Directory completion
COMPREPLY=($(compgen -d -- "$cur"))
;;
*)
# Check if command is for robot run
if [[ "${words[1]}" == "robot" && "${words[2]}" == "run" ]]; then
COMPREPLY=($(compgen -W "$robot_run_options $common_options" -- "$cur"))
else
COMPREPLY=()
fi
;;
esac
;;
*)
COMPREPLY=()
;;
esac
;;
esac
}
# Register the completion function
complete -F _drex_completion drex