Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-p2p/go-ipfs-bin/files/, net-p2p/go-ipfs-bin/
Date: Thu, 08 Feb 2018 20:03:45
Message-Id: 1518120200.dcb439113e0d205f2b83ae15891dce2b85644e49.mgorny@gentoo
1 commit: dcb439113e0d205f2b83ae15891dce2b85644e49
2 Author: David Roman <davidroman96 <AT> gmail <DOT> com>
3 AuthorDate: Tue Feb 6 15:12:32 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 8 20:03:20 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dcb43911
7
8 net-p2p/go-ipfs-bin: add bash completion file
9
10 Closes: https://bugs.gentoo.org/643636
11 Closes: https://github.com/gentoo/gentoo/pull/7092
12
13 net-p2p/go-ipfs-bin/files/ipfs-completion.bash | 959 +++++++++++++++++++++++
14 net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.13-r1.ebuild | 28 +
15 2 files changed, 987 insertions(+)
16
17 diff --git a/net-p2p/go-ipfs-bin/files/ipfs-completion.bash b/net-p2p/go-ipfs-bin/files/ipfs-completion.bash
18 new file mode 100644
19 index 00000000000..27f83fdef68
20 --- /dev/null
21 +++ b/net-p2p/go-ipfs-bin/files/ipfs-completion.bash
22 @@ -0,0 +1,959 @@
23 +_ipfs_comp()
24 +{
25 + COMPREPLY=( $(compgen -W "$1" -- ${word}) )
26 + if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} == "--"*"=" ]] ; then
27 + # If there's only one option, with =, then discard space
28 + compopt -o nospace
29 + fi
30 +}
31 +
32 +_ipfs_help_only()
33 +{
34 + _ipfs_comp "--help"
35 +}
36 +
37 +_ipfs_add()
38 +{
39 + if [[ "${prev}" == "--chunker" ]] ; then
40 + _ipfs_comp "placeholder1 placeholder2 placeholder3" # TODO: a) Give real options, b) Solve autocomplete bug for "="
41 + elif [ "${prev}" == "--pin" ] ; then
42 + _ipfs_comp "true false"
43 + elif [[ ${word} == -* ]] ; then
44 + _ipfs_comp "--recursive --quiet --silent --progress --trickle --only-hash --wrap-with-directory --hidden --chunker= --pin= --raw-leaves --help "
45 + else
46 + _ipfs_filesystem_complete
47 + fi
48 +}
49 +
50 +_ipfs_bitswap()
51 +{
52 + ipfs_comp "ledger stat unwant wantlist --help"
53 +}
54 +
55 +_ipfs_bitswap_ledger()
56 +{
57 + _ipfs_help_only
58 +}
59 +
60 +_ipfs_bitswap_stat()
61 +{
62 + _ipfs_help_only
63 +}
64 +
65 +_ipfs_bitswap_unwant()
66 +{
67 + _ipfs_help_only
68 +}
69 +
70 +_ipfs_bitswap_wantlist()
71 +{
72 + ipfs_comp "--peer= --help"
73 +}
74 +
75 +_ipfs_bitswap_unwant()
76 +{
77 + _ipfs_help_only
78 +}
79 +
80 +_ipfs_block()
81 +{
82 + _ipfs_comp "get put rm stat --help"
83 +}
84 +
85 +_ipfs_block_get()
86 +{
87 + _ipfs_hash_complete
88 +}
89 +
90 +_ipfs_block_put()
91 +{
92 + if [ "${prev}" == "--format" ] ; then
93 + _ipfs_comp "v0 placeholder2 placeholder3" # TODO: a) Give real options, b) Solve autocomplete bug for "="
94 + elif [[ ${word} == -* ]] ; then
95 + _ipfs_comp "--format= --help"
96 + else
97 + _ipfs_filesystem_complete
98 + fi
99 +}
100 +
101 +_ipfs_block_rm()
102 +{
103 + if [[ ${word} == -* ]] ; then
104 + _ipfs_comp "--force --quiet --help"
105 + else
106 + _ipfs_hash_complete
107 + fi
108 +}
109 +
110 +_ipfs_block_stat()
111 +{
112 + _ipfs_hash_complete
113 +}
114 +
115 +_ipfs_bootstrap()
116 +{
117 + _ipfs_comp "add list rm --help"
118 +}
119 +
120 +_ipfs_bootstrap_add()
121 +{
122 + _ipfs_comp "default --help"
123 +}
124 +
125 +_ipfs_bootstrap_list()
126 +{
127 + _ipfs_help_only
128 +}
129 +
130 +_ipfs_bootstrap_rm()
131 +{
132 + _ipfs_comp "all --help"
133 +}
134 +
135 +_ipfs_cat()
136 +{
137 + if [[ ${prev} == */* ]] ; then
138 + COMPREPLY=() # Only one argument allowed
139 + elif [[ ${word} == */* ]] ; then
140 + _ipfs_hash_complete
141 + else
142 + _ipfs_pinned_complete
143 + fi
144 +}
145 +
146 +_ipfs_commands()
147 +{
148 + _ipfs_comp "--flags --help"
149 +}
150 +
151 +_ipfs_config()
152 +{
153 + if [[ ${word} == -* ]] ; then
154 + _ipfs_comp "--bool --json"
155 + elif [[ ${prev} == *.* ]] ; then
156 + COMPREPLY=() # Only one subheader of the config can be shown or edited.
157 + else
158 + _ipfs_comp "show edit replace"
159 + fi
160 +}
161 +
162 +_ipfs_config_edit()
163 +{
164 + _ipfs_help_only
165 +}
166 +
167 +_ipfs_config_replace()
168 +{
169 + if [[ ${word} == -* ]] ; then
170 + _ipfs_comp "--help"
171 + else
172 + _ipfs_filesystem_complete
173 + fi
174 +}
175 +
176 +_ipfs_config_show()
177 +{
178 + _ipfs_help_only
179 +}
180 +
181 +_ipfs_daemon()
182 +{
183 + if [[ ${prev} == "--routing" ]] ; then
184 + _ipfs_comp "dht dhtclient none" # TODO: Solve autocomplete bug for "="
185 + elif [[ ${prev} == "--mount-ipfs" ]] || [[ ${prev} == "--mount-ipns" ]] || [[ ${prev} == "=" ]]; then
186 + _ipfs_filesystem_complete
187 + elif [[ ${word} == -* ]] ; then
188 + _ipfs_comp "--init --routing= --mount --writable --mount-ipfs= \
189 + --mount-ipns= --unrestricted-api --disable-transport-encryption \
190 + -- enable-gc --manage-fdlimit --offline --migrate --help"
191 + fi
192 +}
193 +
194 +_ipfs_dag()
195 +{
196 + _ipfs_comp "get put --help"
197 +}
198 +
199 +_ipfs_dag_get()
200 +{
201 + _ipfs_help_only
202 +}
203 +
204 +_ipfs_dag_put()
205 +{
206 + if [[ ${prev} == "--format" ]] ; then
207 + _ipfs_comp "cbor placeholder1" # TODO: a) Which format more then cbor is valid? b) Solve autocomplete bug for "="
208 + elif [[ ${prev} == "--input-enc" ]] ; then
209 + _ipfs_comp "json placeholder1" # TODO: a) Which format more then json is valid? b) Solve autocomplete bug for "="
210 + elif [[ ${word} == -* ]] ; then
211 + _ipfs_comp "--format= --input-enc= --help"
212 + else
213 + _ipfs_filesystem_complete
214 + fi
215 +}
216 +
217 +_ipfs_dht()
218 +{
219 + _ipfs_comp "findpeer findprovs get provide put query --help"
220 +}
221 +
222 +_ipfs_dht_findpeer()
223 +{
224 + _ipfs_comp "--verbose --help"
225 +}
226 +
227 +_ipfs_dht_findprovs()
228 +{
229 + _ipfs_comp "--verbose --help"
230 +}
231 +
232 +_ipfs_dht_get()
233 +{
234 + _ipfs_comp "--verbose --help"
235 +}
236 +
237 +_ipfs_dht_provide()
238 +{
239 + _ipfs_comp "--recursive --verbose --help"
240 +}
241 +
242 +_ipfs_dht_put()
243 +{
244 + _ipfs_comp "--verbose --help"
245 +}
246 +
247 +_ipfs_dht_query()
248 +{
249 + _ipfs_comp "--verbose --help"
250 +}
251 +
252 +_ipfs_diag()
253 +{
254 + _ipfs_comp "sys cmds net --help"
255 +}
256 +
257 +_ipfs_diag_cmds()
258 +{
259 + if [[ ${prev} == "clear" ]] ; then
260 + return 0
261 + elif [[ ${prev} =~ ^-?[0-9]+$ ]] ; then
262 + _ipfs_comp "ns us µs ms s m h" # TODO: Trigger with out space, eg. "ipfs diag set-time 10ns" not "... set-time 10 ns"
263 + elif [[ ${prev} == "set-time" ]] ; then
264 + _ipfs_help_only
265 + elif [[ ${word} == -* ]] ; then
266 + _ipfs_comp "--verbose --help"
267 + else
268 + _ipfs_comp "clear set-time"
269 + fi
270 +}
271 +
272 +_ipfs_diag_sys()
273 +{
274 + _ipfs_help_only
275 +}
276 +
277 +_ipfs_diag_net()
278 +{
279 + if [[ ${prev} == "--vis" ]] ; then
280 + _ipfs_comp "d3 dot text" # TODO: Solve autocomplete bug for "="
281 + elif [[ ${word} == -* ]] ; then
282 + _ipfs_comp "--timeout= --vis= --help"
283 + fi
284 +}
285 +
286 +_ipfs_dns()
287 +{
288 + if [[ ${word} == -* ]] ; then
289 + _ipfs_comp "--recursive --help"
290 + fi
291 +}
292 +
293 +_ipfs_files()
294 +{
295 + _ipfs_comp "mv rm flush read write cp ls mkdir stat"
296 +}
297 +
298 +_ipfs_files_mv()
299 +{
300 + if [[ ${word} == -* ]] ; then
301 + _ipfs_comp "--recursive --flush"
302 + elif [[ ${word} == /* ]] ; then
303 + _ipfs_files_complete
304 + else
305 + COMPREPLY=( / )
306 + [[ $COMPREPLY = */ ]] && compopt -o nospace
307 + fi
308 +}
309 +
310 +_ipfs_files_rm()
311 +{
312 + if [[ ${word} == -* ]] ; then
313 + _ipfs_comp "--recursive --flush"
314 + elif [[ ${word} == /* ]] ; then
315 + _ipfs_files_complete
316 + else
317 + COMPREPLY=( / )
318 + [[ $COMPREPLY = */ ]] && compopt -o nospace
319 + fi
320 +}
321 +_ipfs_files_flush()
322 +{
323 + if [[ ${word} == /* ]] ; then
324 + _ipfs_files_complete
325 + else
326 + COMPREPLY=( / )
327 + [[ $COMPREPLY = */ ]] && compopt -o nospace
328 + fi
329 +}
330 +
331 +_ipfs_files_read()
332 +{
333 + if [[ ${prev} == "--count" ]] || [[ ${prev} == "--offset" ]] ; then
334 + COMPREPLY=() # Numbers, just keep it empty
335 + elif [[ ${word} == -* ]] ; then
336 + _ipfs_comp "--offset --count --help"
337 + elif [[ ${word} == /* ]] ; then
338 + _ipfs_files_complete
339 + else
340 + COMPREPLY=( / )
341 + [[ $COMPREPLY = */ ]] && compopt -o nospace
342 + fi
343 +}
344 +
345 +_ipfs_files_write()
346 +{
347 + if [[ ${prev} == "--count" ]] || [[ ${prev} == "--offset" ]] ; then # Dirty check
348 + COMPREPLY=() # Numbers, just keep it empty
349 + elif [[ ${word} == -* ]] ; then
350 + _ipfs_comp "--offset --count --create --truncate --help"
351 + elif [[ ${prev} == /* ]] ; then
352 + _ipfs_filesystem_complete
353 + elif [[ ${word} == /* ]] ; then
354 + _ipfs_files_complete
355 + else
356 + COMPREPLY=( / )
357 + [[ $COMPREPLY = */ ]] && compopt -o nospace
358 + fi
359 +}
360 +
361 +_ipfs_files_cp()
362 +{
363 + if [[ ${word} == /* ]] ; then
364 + _ipfs_files_complete
365 + else
366 + COMPREPLY=( / )
367 + [[ $COMPREPLY = */ ]] && compopt -o nospace
368 + fi
369 +}
370 +
371 +_ipfs_files_ls()
372 +{
373 + if [[ ${word} == -* ]] ; then
374 + _ipfs_comp "-l --help"
375 + elif [[ ${prev} == /* ]] ; then
376 + COMPREPLY=() # Path exist
377 + elif [[ ${word} == /* ]] ; then
378 + _ipfs_files_complete
379 + else
380 + COMPREPLY=( / )
381 + [[ $COMPREPLY = */ ]] && compopt -o nospace
382 + fi
383 +}
384 +
385 +_ipfs_files_mkdir()
386 +{
387 + if [[ ${word} == -* ]] ; then
388 + _ipfs_comp "--parents --help"
389 +
390 + elif [[ ${prev} == /* ]] ; then
391 + COMPREPLY=() # Path exist
392 + elif [[ ${word} == /* ]] ; then
393 + _ipfs_files_complete
394 + else
395 + COMPREPLY=( / )
396 + [[ $COMPREPLY = */ ]] && compopt -o nospace
397 + fi
398 +}
399 +
400 +_ipfs_files_stat()
401 +{
402 + if [[ ${prev} == /* ]] ; then
403 + COMPREPLY=() # Path exist
404 + elif [[ ${word} == /* ]] ; then
405 + _ipfs_files_complete
406 + else
407 + COMPREPLY=( / )
408 + [[ $COMPREPLY = */ ]] && compopt -o nospace
409 + fi
410 +}
411 +
412 +_ipfs_file()
413 +{
414 + if [[ ${prev} == "ls" ]] ; then
415 + _ipfs_hash_complete
416 + else
417 + _ipfs_comp "ls --help"
418 + fi
419 +}
420 +
421 +_ipfs_file_ls()
422 +{
423 + _ipfs_help_only
424 +}
425 +
426 +_ipfs_get()
427 +{
428 + if [ "${prev}" == "--output" ] ; then
429 + compopt -o default # Re-enable default file read
430 + COMPREPLY=()
431 + elif [ "${prev}" == "--compression-level" ] ; then
432 + _ipfs_comp "-1 1 2 3 4 5 6 7 8 9" # TODO: Solve autocomplete bug for "="
433 + elif [[ ${word} == -* ]] ; then
434 + _ipfs_comp "--output= --archive --compress --compression-level= --help"
435 + else
436 + _ipfs_hash_complete
437 + fi
438 +}
439 +
440 +_ipfs_id()
441 +{
442 + if [[ ${word} == -* ]] ; then
443 + _ipfs_comp "--format= --help"
444 + fi
445 +}
446 +
447 +_ipfs_init()
448 +{
449 + _ipfs_comp "--bits --force --empty-repo --help"
450 +}
451 +
452 +_ipfs_log()
453 +{
454 + _ipfs_comp "level ls tail --help"
455 +}
456 +
457 +_ipfs_log_level()
458 +{
459 + # TODO: auto-complete subsystem and level
460 + _ipfs_help_only
461 +}
462 +
463 +_ipfs_log_ls()
464 +{
465 + _ipfs_help_only
466 +}
467 +
468 +_ipfs_log_tail()
469 +{
470 + _ipfs_help_only
471 +}
472 +
473 +_ipfs_ls()
474 +{
475 + if [[ ${word} == -* ]] ; then
476 + _ipfs_comp "--headers --resolve-type=false --help"
477 + else
478 + _ipfs_hash_complete
479 + fi
480 +}
481 +
482 +_ipfs_mount()
483 +{
484 + if [[ ${prev} == "--ipfs-path" ]] || [[ ${prev} == "--ipns-path" ]] || [[ ${prev} == "=" ]] ; then
485 + _ipfs_filesystem_complete
486 + elif [[ ${word} == -* ]] ; then
487 + _ipfs_comp "--ipfs-path= --ipns-path= --help"
488 + fi
489 +}
490 +
491 +_ipfs_name()
492 +{
493 + _ipfs_comp "publish resolve --help"
494 +}
495 +
496 +_ipfs_name_publish()
497 +{
498 + if [[ ${prev} == "--lifetime" ]] || [[ ${prev} == "--ttl" ]] ; then
499 + COMPREPLY=() # Accept only numbers
500 + elif [[ ${prev} =~ ^-?[0-9]+$ ]] ; then
501 + _ipfs_comp "ns us µs ms s m h" # TODO: Trigger without space, eg. "ipfs diag set-time 10ns" not "... set-time 10 ns"
502 + elif [[ ${word} == -* ]] ; then
503 + _ipfs_comp "--resolve --lifetime --ttl --help"
504 + elif [[ ${word} == */ ]]; then
505 + _ipfs_hash_complete
506 + else
507 + _ipfs_pinned_complete
508 + fi
509 +}
510 +
511 +_ipfs_name_resolve()
512 +{
513 + if [[ ${word} == -* ]] ; then
514 + _ipfs_comp "--recursive --nocache --help"
515 + fi
516 +}
517 +
518 +_ipfs_object()
519 +{
520 + _ipfs_comp "data diff get links new patch put stat --help"
521 +}
522 +
523 +_ipfs_object_data()
524 +{
525 + _ipfs_hash_complete
526 +}
527 +
528 +_ipfs_object_diff()
529 +{
530 + if [[ ${word} == -* ]] ; then
531 + _ipfs_comp "--verbose --help"
532 + else
533 + _ipfs_hash_complete
534 + fi
535 +}
536 +
537 +
538 +_ipfs_object_get()
539 +{
540 + if [ "${prev}" == "--encoding" ] ; then
541 + _ipfs_comp "protobuf json xml"
542 + elif [[ ${word} == -* ]] ; then
543 + _ipfs_comp "--encoding --help"
544 + else
545 + _ipfs_hash_complete
546 + fi
547 +}
548 +
549 +_ipfs_object_links()
550 +{
551 + if [[ ${word} == -* ]] ; then
552 + _ipfs_comp "--headers --help"
553 + else
554 + _ipfs_hash_complete
555 + fi
556 +}
557 +
558 +_ipfs_object_new()
559 +{
560 + if [[ ${word} == -* ]] ; then
561 + _ipfs_comp "--help"
562 + else
563 + _ipfs_comp "unixfs-dir"
564 + fi
565 +}
566 +
567 +_ipfs_object_patch()
568 +{
569 + if [[ -n "${COMP_WORDS[3]}" ]] ; then # Root merkledag object exist
570 + case "${COMP_WORDS[4]}" in
571 + append-data)
572 + _ipfs_help_only
573 + ;;
574 + add-link)
575 + if [[ ${word} == -* ]] && [[ ${prev} == "add-link" ]] ; then # Dirty check
576 + _ipfs_comp "--create"
577 + #else
578 + # TODO: Hash path autocomplete. This is tricky, can be hash or a name.
579 + fi
580 + ;;
581 + rm-link)
582 + _ipfs_hash_complete
583 + ;;
584 + set-data)
585 + _ipfs_filesystem_complete
586 + ;;
587 + *)
588 + _ipfs_comp "append-data add-link rm-link set-data"
589 + ;;
590 + esac
591 + else
592 + _ipfs_hash_complete
593 + fi
594 +}
595 +
596 +_ipfs_object_put()
597 +{
598 + if [ "${prev}" == "--inputenc" ] ; then
599 + _ipfs_comp "protobuf json"
600 + elif [ "${prev}" == "--datafieldenc" ] ; then
601 + _ipfs_comp "text base64"
602 + elif [[ ${word} == -* ]] ; then
603 + _ipfs_comp "--inputenc --datafieldenc --help"
604 + else
605 + _ipfs_hash_complete
606 + fi
607 +}
608 +
609 +_ipfs_object_stat()
610 +{
611 + _ipfs_hash_complete
612 +}
613 +
614 +_ipfs_pin()
615 +{
616 + _ipfs_comp "rm ls add --help"
617 +}
618 +
619 +_ipfs_pin_add()
620 +{
621 + if [[ ${word} == -* ]] ; then
622 + _ipfs_comp "--recursive= --help"
623 + elif [[ ${word} == */ ]] && [[ ${word} != "/ipfs/" ]] ; then
624 + _ipfs_hash_complete
625 + fi
626 +}
627 +
628 +_ipfs_pin_ls()
629 +{
630 + if [[ ${prev} == "--type" ]] || [[ ${prev} == "-t" ]] ; then
631 + _ipfs_comp "direct indirect recursive all" # TODO: Solve autocomplete bug for
632 + elif [[ ${word} == -* ]] ; then
633 + _ipfs_comp "--count --quiet --type= --help"
634 + elif [[ ${word} == */ ]] && [[ ${word} != "/ipfs/" ]] ; then
635 + _ipfs_hash_complete
636 + fi
637 +}
638 +
639 +_ipfs_pin_rm()
640 +{
641 + if [[ ${word} == -* ]] ; then
642 + _ipfs_comp "--recursive --help"
643 + elif [[ ${word} == */ ]] && [[ ${word} != "/ipfs/" ]] ; then
644 + COMPREPLY=() # TODO: _ipfs_hash_complete() + List local pinned hashes as default?
645 + fi
646 +}
647 +
648 +_ipfs_ping()
649 +{
650 + _ipfs_comp "--count= --help"
651 +}
652 +
653 +_ipfs_pubsub()
654 +{
655 + _ipfs_comp "ls peers pub sub --help"
656 +}
657 +
658 +_ipfs_pubsub_ls()
659 +{
660 + _ipfs_help_only
661 +}
662 +
663 +_ipfs_pubsub_peers()
664 +{
665 + _ipfs_help_only
666 +}
667 +
668 +_ipfs_pubsub_pub()
669 +{
670 + _ipfs_help_only
671 +}
672 +
673 +_ipfs_pubsub_sub()
674 +{
675 + _ipfs_comp "--discover --help"
676 +}
677 +
678 +_ipfs_refs()
679 +{
680 + if [ "${prev}" == "--format" ] ; then
681 + _ipfs_comp "src dst linkname"
682 + elif [[ ${word} == -* ]] ; then
683 + _ipfs_comp "local --format= --edges --unique --recursive --help"
684 + #else
685 + # TODO: Use "ipfs ref" and combine it with autocomplete, see _ipfs_hash_complete
686 + fi
687 +}
688 +
689 +_ipfs_refs_local()
690 +{
691 + _ipfs_help_only
692 +}
693 +
694 +_ipfs_repo()
695 +{
696 + _ipfs_comp "fsck gc stat verify version --help"
697 +}
698 +
699 +_ipfs_repo_version()
700 +{
701 + _ipfs_comp "--quiet --help"
702 +}
703 +
704 +_ipfs_repo_verify()
705 +{
706 + _ipfs_help_only
707 +}
708 +
709 +_ipfs_repo_gc()
710 +{
711 + _ipfs_comp "--quiet --help"
712 +}
713 +
714 +_ipfs_repo_stat()
715 +{
716 + _ipfs_comp "--human --help"
717 +}
718 +
719 +_ipfs_repo_fsck()
720 +{
721 + _ipfs_help_only
722 +}
723 +
724 +_ipfs_resolve()
725 +{
726 + if [[ ${word} == /ipfs/* ]] ; then
727 + _ipfs_hash_complete
728 + elif [[ ${word} == /ipns/* ]] ; then
729 + COMPREPLY=() # Can't autocomplete ipns
730 + elif [[ ${word} == -* ]] ; then
731 + _ipfs_comp "--recursive --help"
732 + else
733 + opts="/ipns/ /ipfs/"
734 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
735 + [[ $COMPREPLY = */ ]] && compopt -o nospace
736 + fi
737 +}
738 +
739 +_ipfs_stats()
740 +{
741 + _ipfs_comp "bitswap bw repo --help"
742 +}
743 +
744 +_ipfs_stats_bitswap()
745 +{
746 + _ipfs_help_only
747 +}
748 +
749 +_ipfs_stats_bw()
750 +{
751 + # TODO: Which protocol is valid?
752 + _ipfs_comp "--peer= --proto= --poll --interval= --help"
753 +}
754 +
755 +_ipfs_stats_repo()
756 +{
757 + _ipfs_comp "--human= --help"
758 +}
759 +
760 +_ipfs_swarm()
761 +{
762 + _ipfs_comp "addrs connect disconnect filters peers --help"
763 +}
764 +
765 +_ipfs_swarm_addrs()
766 +{
767 + _ipfs_comp "local --help"
768 +}
769 +
770 +_ipfs_swarm_addrs_local()
771 +{
772 + _ipfs_comp "--id --help"
773 +}
774 +
775 +_ipfs_swarm_connect()
776 +{
777 + _ipfs_multiaddr_complete
778 +}
779 +
780 +_ipfs_swarm_disconnect()
781 +{
782 + local OLDIFS="$IFS" ; local IFS=$'\n' # Change divider for iterator one line below
783 + opts=$(for x in `ipfs swarm peers`; do echo ${x} ; done)
784 + IFS="$OLDIFS" # Reset divider to space, ' '
785 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
786 + [[ $COMPREPLY = */ ]] && compopt -o nospace -o filenames
787 +}
788 +
789 +_ipfs_swarm_filters()
790 +{
791 + if [[ ${prev} == "add" ]] || [[ ${prev} == "rm" ]]; then
792 + _ipfs_multiaddr_complete
793 + else
794 + _ipfs_comp "add rm --help"
795 + fi
796 +}
797 +
798 +_ipfs_swarm_filters_add()
799 +{
800 + _ipfs_help_only
801 +}
802 +
803 +_ipfs_swarm_filters_rm()
804 +{
805 + _ipfs_help_only
806 +}
807 +
808 +_ipfs_swarm_peers()
809 +{
810 + _ipfs_help_only
811 +}
812 +
813 +_ipfs_tar()
814 +{
815 + _ipfs_comp "add cat --help"
816 +}
817 +
818 +_ipfs_tar_add()
819 +{
820 + if [[ ${word} == -* ]] ; then
821 + _ipfs_comp "--help"
822 + else
823 + _ipfs_filesystem_complete
824 + fi
825 +}
826 +
827 +_ipfs_tar_cat()
828 +{
829 + if [[ ${word} == -* ]] ; then
830 + _ipfs_comp "--help"
831 + else
832 + _ipfs_filesystem_complete
833 + fi
834 +}
835 +
836 +_ipfs_update()
837 +{
838 + if [[ ${word} == -* ]] ; then
839 + _ipfs_comp "--version" # TODO: How does "--verbose" option work?
840 + else
841 + _ipfs_comp "versions version install stash revert fetch"
842 + fi
843 +}
844 +
845 +_ipfs_update_install()
846 +{
847 + if [[ ${prev} == v*.*.* ]] ; then
848 + COMPREPLY=()
849 + elif [[ ${word} == -* ]] ; then
850 + _ipfs_comp "--version"
851 + else
852 + local OLDIFS="$IFS" ; local IFS=$'\n' # Change divider for iterator one line below
853 + opts=$(for x in `ipfs update versions`; do echo ${x} ; done)
854 + IFS="$OLDIFS" # Reset divider to space, ' '
855 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
856 + fi
857 +}
858 +
859 +_ipfs_update_stash()
860 +{
861 + if [[ ${word} == -* ]] ; then
862 + _ipfs_comp "--tag --help"
863 + fi
864 +}
865 +_ipfs_update_fetch()
866 +{
867 + if [[ ${prev} == "--output" ]] ; then
868 + _ipfs_filesystem_complete
869 + elif [[ ${word} == -* ]] ; then
870 + _ipfs_comp "--output --help"
871 + fi
872 +}
873 +
874 +_ipfs_version()
875 +{
876 + _ipfs_comp "--number --commit --repo"
877 +}
878 +
879 +_ipfs_hash_complete()
880 +{
881 + local lastDir=${word%/*}/
882 + echo "LastDir: ${lastDir}" >> ~/Downloads/debug-ipfs.txt
883 + local OLDIFS="$IFS" ; local IFS=$'\n' # Change divider for iterator one line below
884 + opts=$(for x in `ipfs file ls ${lastDir}`; do echo ${lastDir}${x}/ ; done) # TODO: Implement "ipfs file ls -F" to get rid of frontslash after files. This take long time to run first time on a new shell.
885 + echo "Options: ${opts}" >> ~/Downloads/debug-ipfs.txt
886 + IFS="$OLDIFS" # Reset divider to space, ' '
887 + echo "Current: ${word}" >> ~/Downloads/debug-ipfs.txt
888 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
889 + echo "Suggestion: ${COMPREPLY}" >> ~/Downloads/debug-ipfs.txt
890 + [[ $COMPREPLY = */ ]] && compopt -o nospace -o filenames # Removing whitespace after output & handle output as filenames. (Only printing the latest folder of files.)
891 + return 0
892 +}
893 +
894 +_ipfs_files_complete()
895 +{
896 + local lastDir=${word%/*}/
897 + local OLDIFS="$IFS" ; local IFS=$'\n' # Change divider for iterator one line below
898 + opts=$(for x in `ipfs files ls ${lastDir}`; do echo ${lastDir}${x}/ ; done) # TODO: Implement "ipfs files ls -F" to get rid of frontslash after files. This does currently throw "Error: /cats/foo/ is not a directory"
899 + IFS="$OLDIFS" # Reset divider to space, ' '
900 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
901 + [[ $COMPREPLY = */ ]] && compopt -o nospace -o filenames
902 + return 0
903 +}
904 +
905 +_ipfs_multiaddr_complete()
906 +{
907 + local lastDir=${word%/*}/
908 + # Special case
909 + if [[ ${word} == */"ipcidr"* ]] ; then # TODO: Broken, fix it.
910 + opts="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" # TODO: IPv6?
911 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
912 + # "Loop"
913 + elif [[ ${word} == /*/ ]] || [[ ${word} == /*/* ]] ; then
914 + if [[ ${word} == /*/*/*/*/*/ ]] ; then
915 + COMPREPLY=()
916 + elif [[ ${word} == /*/*/*/*/ ]] ; then
917 + word=${word##*/}
918 + opts="ipfs/ "
919 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
920 + elif [[ ${word} == /*/*/*/ ]] ; then
921 + word=${word##*/}
922 + opts="4001/ "
923 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
924 + elif [[ ${word} == /*/*/ ]] ; then
925 + word=${word##*/}
926 + opts="udp/ tcp/ ipcidr/"
927 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
928 + elif [[ ${word} == /*/ ]] ; then
929 + COMPREPLY=() # TODO: This need to return something to NOT break the function. Maybe a "/" in the end as well due to -o filename option.
930 + fi
931 + COMPREPLY=${lastDir}${COMPREPLY}
932 + else # start case
933 + opts="/ip4/ /ip6/"
934 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) )
935 + fi
936 + [[ $COMPREPLY = */ ]] && compopt -o nospace -o filenames
937 + return 0
938 +}
939 +
940 +_ipfs_pinned_complete()
941 +{
942 + local OLDIFS="$IFS" ; local IFS=$'\n'
943 + local pinned=$(ipfs pin ls)
944 + COMPREPLY=( $(compgen -W "${pinned}" -- ${word}) )
945 + IFS="$OLDIFS"
946 + if [[ ${#COMPREPLY[*]} -eq 1 ]]; then # Only one completion, remove pretty output
947 + COMPREPLY=( ${COMPREPLY[0]/ *//} ) #Remove ' ' and everything after
948 + [[ $COMPREPLY = */ ]] && compopt -o nospace # Removing whitespace after output
949 + fi
950 +}
951 +_ipfs_filesystem_complete()
952 +{
953 + compopt -o default # Re-enable default file read
954 + COMPREPLY=()
955 +}
956 +
957 +_ipfs()
958 +{
959 + COMPREPLY=()
960 + compopt +o default # Disable default to not deny completion, see: http://stackoverflow.com/a/19062943/1216348
961 +
962 + local word="${COMP_WORDS[COMP_CWORD]}"
963 + local prev="${COMP_WORDS[COMP_CWORD-1]}"
964 +
965 + case "${COMP_CWORD}" in
966 + 1)
967 + local opts="add bitswap block bootstrap cat commands config daemon dag dht \
968 + diag dns file files get id init log ls mount name object pin ping pubsub \
969 + refs repo resolve stats swarm tar update version"
970 + COMPREPLY=( $(compgen -W "${opts}" -- ${word}) );;
971 + 2)
972 + local command="${COMP_WORDS[1]}"
973 + eval "_ipfs_$command" 2> /dev/null ;;
974 + *)
975 + local command="${COMP_WORDS[1]}"
976 + local subcommand="${COMP_WORDS[2]}"
977 + eval "_ipfs_${command}_${subcommand}" 2> /dev/null && return
978 + eval "_ipfs_$command" 2> /dev/null ;;
979 + esac
980 +}
981 +complete -F _ipfs ipfs
982
983 diff --git a/net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.13-r1.ebuild b/net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.13-r1.ebuild
984 new file mode 100644
985 index 00000000000..5771da30b8d
986 --- /dev/null
987 +++ b/net-p2p/go-ipfs-bin/go-ipfs-bin-0.4.13-r1.ebuild
988 @@ -0,0 +1,28 @@
989 +# Copyright 1999-2018 Gentoo Foundation
990 +# Distributed under the terms of the GNU General Public License v2
991 +
992 +EAPI=6
993 +
994 +inherit bash-completion-r1
995 +
996 +DESCRIPTION="go-ipfs is the main implementation of IPFS."
997 +HOMEPAGE="https://ipfs.io/"
998 +SRC_URI="amd64? ( https://dist.ipfs.io/go-ipfs/v${PV}/go-ipfs_v${PV}_linux-amd64.tar.gz )
999 + x86? ( https://dist.ipfs.io/go-ipfs/v${PV}/go-ipfs_v${PV}_linux-386.tar.gz )
1000 + arm? ( https://dist.ipfs.io/go-ipfs/v${PV}/go-ipfs_v${PV}_linux-arm.tar.gz )"
1001 +
1002 +LICENSE="MIT"
1003 +SLOT="0"
1004 +KEYWORDS="-* ~amd64 ~arm ~x86"
1005 +IUSE="+fuse"
1006 +
1007 +RDEPEND="fuse? ( sys-fs/fuse )"
1008 +S="${WORKDIR}/go-ipfs"
1009 +
1010 +QA_PREBUILT="/usr/bin/ipfs"
1011 +
1012 +src_install() {
1013 + dobin ipfs
1014 +
1015 + newbashcomp "${FILESDIR}/ipfs-completion.bash" "${PN}"
1016 +}