github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/misc/completion/ipfs-completion.bash (about) 1 _ipfs_comp() 2 { 3 COMPREPLY=( $(compgen -W "$1" -- ${word}) ) 4 } 5 6 _ipfs_help_only() 7 { 8 _ipfs_comp "--help" 9 } 10 11 _ipfs_add() 12 { 13 _ipfs_comp "--recursive --quiet --progress --trickle --only-hash 14 --wrap-with-directory --hidden --help" 15 } 16 17 _ipfs_bitswap() 18 { 19 ipfs_comp "stat wantlist --help" 20 } 21 22 _ipfs_bitswap_stat() 23 { 24 _ipfs_help_only 25 } 26 27 _ipfs_bitswap_wantlist() 28 { 29 ipfs_comp "--peer= --help" 30 } 31 32 _ipfs_block() 33 { 34 _ipfs_comp "get put stat --help" 35 } 36 37 _ipfs_block_get() 38 { 39 _ipfs_help_only 40 } 41 42 _ipfs_block_put() 43 { 44 _ipfs_help_only 45 } 46 47 _ipfs_block_stat() 48 { 49 _ipfs_help_only 50 } 51 52 _ipfs_bootstrap() 53 { 54 _ipfs_comp "add list rm --help" 55 } 56 57 _ipfs_bootstrap_add() 58 { 59 _ipfs_comp "--default --help" 60 } 61 62 _ipfs_bootstrap_list() 63 { 64 _ipfs_help_only 65 } 66 67 _ipfs_bootstrap_rm() 68 { 69 _ipfs_comp "--all --help" 70 } 71 72 _ipfs_cat() 73 { 74 _ipfs_help_only 75 } 76 77 _ipfs_commands() 78 { 79 _ipfs_help_only 80 } 81 82 _ipfs_config() 83 { 84 # TODO: auto-complete existing config keys 85 _ipfs_comp "edit replace show --bool --json --help" 86 } 87 88 _ipfs_config_edit() 89 { 90 _ipfs_help_only 91 } 92 93 _ipfs_config_replace() 94 { 95 # TODO: auto-complete with a filename 96 _ipfs_help_only 97 } 98 99 _ipfs_config_show() 100 { 101 _ipfs_help_only 102 } 103 104 _ipfs_daemon() 105 { 106 _ipfs_comp "--init --routing= --mount --writable --mount-ipfs= \ 107 --mount-ipns= --unrestricted-api --disable-transport-encryption \ 108 --help" 109 } 110 111 _ipfs_dht() 112 { 113 _ipfs_comp "findpeer findprovs get put query --help" 114 } 115 116 _ipfs_dht_findpeer() 117 { 118 _ipfs_help_only 119 } 120 121 _ipfs_dht_findprovs() 122 { 123 _ipfs_comp "--verbose --help" 124 } 125 126 _ipfs_dht_get() 127 { 128 _ipfs_comp "--verbose --help" 129 } 130 131 _ipfs_dht_put() 132 { 133 _ipfs_comp "--verbose --help" 134 } 135 136 _ipfs_dht_query() 137 { 138 _ipfs_comp "--verbose --help" 139 } 140 141 _ipfs_diag() 142 { 143 _ipfs_comp "net --help" 144 } 145 146 _ipfs_diag_net() 147 { 148 # TODO: auto-complete -vis=* 149 _ipfs_comp "--timeout= --vis= --help" 150 } 151 152 _ipfs_dns() 153 { 154 _ipfs_comp "--recursive --help" 155 } 156 157 _ipfs_file() 158 { 159 _ipfs_comp "ls --help" 160 } 161 162 _ipfs_file_ls() 163 { 164 _ipfs_help_only 165 } 166 167 _ipfs_get() 168 { 169 _ipfs_comp "--output= --archive --compress --compression-level= --help" 170 } 171 172 _ipfs_id() 173 { 174 _ipfs_comp "--format= --help" 175 } 176 177 _ipfs_init() 178 { 179 _ipfs_comp "--bits= --force --help" 180 } 181 182 _ipfs_log() 183 { 184 _ipfs_comp "tail level --help" 185 } 186 187 _ipfs_log_level() 188 { 189 # TODO: auto-complete subsystem and level 190 _ipfs_comp "--help" 191 } 192 193 _ipfs_log_tail() 194 { 195 _ipfs_help_only 196 } 197 198 _ipfs_ls() 199 { 200 _ipfs_comp "--headers --help" 201 } 202 203 _ipfs_mount() 204 { 205 _ipfs_comp "--ipfs-path= --ipns-path= --help" 206 } 207 208 _ipfs_name() 209 { 210 _ipfs_comp "publish resolve --help" 211 } 212 213 _ipfs_name_publish() 214 { 215 _ipfs_help_only 216 } 217 218 _ipfs_name_resolve() 219 { 220 _ipfs_comp "--recursive --help" 221 } 222 223 _ipfs_object() 224 { 225 _ipfs_comp "data get links new patch put stat --help" 226 } 227 228 _ipfs_object_data() 229 { 230 _ipfs_help_only 231 } 232 233 _ipfs_object_get() 234 { 235 # TODO: auto-complete encoding 236 _ipfs_comp "--encoding= --help" 237 } 238 239 _ipfs_object_links() 240 { 241 _ipfs_help_only 242 } 243 244 _ipfs_object_new() 245 { 246 _ipfs_help_only 247 } 248 249 _ipfs_object_patch() 250 { 251 _ipfs_help_only 252 } 253 254 _ipfs_object_put() 255 { 256 _ipfs_comp "--inputenc= --help" 257 } 258 259 _ipfs_object_stat() 260 { 261 _ipfs_help_only 262 } 263 264 _ipfs_pin() 265 { 266 _ipfs_comp "rm ls add --help" 267 } 268 269 _ipfs_pin_add() 270 { 271 _ipfs_comp "--recursive --help" 272 } 273 274 _ipfs_pin_ls() 275 { 276 # TODO: auto-complete -type=* 277 _ipfs_comp "--count --quiet --type= --help" 278 } 279 280 _ipfs_pin_rm() 281 { 282 _ipfs_comp "--recursive --help" 283 } 284 285 _ipfs_ping() 286 { 287 _ipfs_comp "--count= --help" 288 } 289 290 _ipfs_refs() 291 { 292 _ipfs_comp "local --format= --edges --unique --recursive --help" 293 } 294 295 _ipfs_refs_local() 296 { 297 _ipfs_help_only 298 } 299 300 _ipfs_repo() 301 { 302 _ipfs_comp "gc --help" 303 } 304 305 _ipfs_repo_gc() 306 { 307 _ipfs_comp "--quiet --help" 308 } 309 310 _ipfs_resolve() 311 { 312 _ipfs_comp "--recursive --help" 313 } 314 315 _ipfs_stats() 316 { 317 _ipfs_comp "bw --help" 318 } 319 320 _ipfs_stats_bw() 321 { 322 _ipfs_comp "--peer= --proto= --poll --interval= --help" 323 } 324 325 _ipfs_swarm() 326 { 327 _ipfs_comp "addrs connect disconnect filters peers --help" 328 } 329 330 _ipfs_swarm_addrs() 331 { 332 _ipfs_comp "local --help" 333 } 334 335 _ipfs_swarm_addrs_local() 336 { 337 _ipfs_comp "--id --help" 338 } 339 340 _ipfs_swarm_connect() 341 { 342 _ipfs_help_only 343 } 344 345 _ipfs_swarm_disconnect() 346 { 347 _ipfs_help_only 348 } 349 350 _ipfs_swarm_filters() 351 { 352 _ipfs_comp "add rm --help" 353 } 354 355 _ipfs_swarm_filters_add() 356 { 357 _ipfs_help_only 358 } 359 360 _ipfs_swarm_filters_rm() 361 { 362 _ipfs_help_only 363 } 364 365 _ipfs_swarm_peers() 366 { 367 _ipfs_help_only 368 } 369 370 _ipfs_tour() 371 { 372 _ipfs_comp "list next restart --help" 373 } 374 375 _ipfs_tour_list() 376 { 377 _ipfs_help_only 378 } 379 380 _ipfs_tour_next() 381 { 382 _ipfs_help_only 383 } 384 385 _ipfs_tour_restart() 386 { 387 _ipfs_help_only 388 } 389 390 _ipfs_update() 391 { 392 _ipfs_help_only 393 } 394 395 _ipfs_version() 396 { 397 _ipfs_comp "--number --help" 398 } 399 400 _ipfs() 401 { 402 COMPREPLY=() 403 local word="${COMP_WORDS[COMP_CWORD]}" 404 405 case "${COMP_CWORD}" in 406 1) 407 local opts="add bitswap block bootstrap cat commands config daemon dht \ 408 diag dns file get id init log ls mount name object pin ping \ 409 refs repo swarm tour update version" 410 COMPREPLY=( $(compgen -W "${opts}" -- ${word}) );; 411 2) 412 local command="${COMP_WORDS[1]}" 413 eval "_ipfs_$command" 2> /dev/null ;; 414 *) 415 local command="${COMP_WORDS[1]}" 416 local subcommand="${COMP_WORDS[2]}" 417 eval "_ipfs_${command}_${subcommand}" 2> /dev/null && return 418 eval "_ipfs_$command" 2> /dev/null ;; 419 esac 420 } 421 complete -F _ipfs ipfs