1
- complete -c tldr -xf -s v -d " print verbose output"
2
- complete -c tldr -xf -l version -d " print version and exit"
3
- complete -c tldr -xf -s h -l help -d " print this help and exit"
4
- complete -c tldr -xf -s u -l update -d " update local database"
5
- complete -c tldr -xf -s c -l clear-cache -d " clear local database"
6
- complete -c tldr -rf -f -s p -l platform -a " linux osx sunos common" -d " select platform, supported are linux / osx / sunos / common"
7
- complete -c tldr -r -s r -l render -a PATH -d " render a local page for testing purpose"
1
+ function __tldr_not_contain_standalone_opt
2
+ __fish_not_contain_opt -s v
3
+ and __fish_not_contain_opt version
4
+ and __fish_not_contain_opt -s l list
5
+ and __fish_not_contain_opt -s h help
6
+ and __fish_not_contain_opt -s u update
7
+ and __fish_not_contain_opt -s c clear-cache
8
+ end
9
+
10
+ function __tldr_no_os_choice_opt
11
+ __fish_not_contain_opt linux osx sunos
12
+ and __fish_not_contain_opt -s r render
13
+ and __tldr_not_contain_standalone_opt
14
+ end
15
+
16
+ function __tldr_no_os_choice_opt_nor_p
17
+ __tldr_no_os_choice_opt
18
+ and __fish_not_contain_opt -s p platform
19
+ end
20
+
21
+ function __tldr_positional
22
+ __fish_use_subcommand
23
+ and __tldr_not_contain_standalone_opt
24
+ end
25
+
26
+ function __tldr_positional_no_os
27
+ __tldr_positional
28
+ and __fish_not_contain_opt linux osx sunos
29
+ and __fish_not_contain_opt -s p platform
30
+ end
31
+
32
+ complete -c tldr -f -n " __fish_not_contain_opt -s v" -s v -d " print verbose output"
33
+ complete -c tldr -f -n __fish_is_first_arg -l version -d " print version and exit"
34
+ complete -c tldr -f -n __fish_is_first_arg -s l -l list -d " list all entries in the local database"
35
+ complete -c tldr -f -n __fish_is_first_arg -s h -l help -d " print help and exit"
36
+ complete -c tldr -f -n __fish_is_first_arg -s u -l update -d " update local database"
37
+ complete -c tldr -f -n __fish_is_first_arg -s c -l clear-cache -d " clear local database"
38
+ complete -c tldr -x -n __tldr_no_os_choice_opt -s p -l platform -d " select platform" -a " linux osx sunos common"
39
+ complete -c tldr -f -n __tldr_no_os_choice_opt_nor_p -l linux -d " show command page for Linux"
40
+ complete -c tldr -f -n __tldr_no_os_choice_opt_nor_p -l osx -d " show command page for macOS"
41
+ complete -c tldr -f -n __tldr_no_os_choice_opt_nor_p -l sunos -d " show command page for SunOS"
42
+ complete -c tldr -rF -n __tldr_positional_no_os -s r -l render -d " render a local page for testing purposes"
8
43
9
44
function __tldr_get_files
10
- set -l files (basename -s .md (find $HOME /.tldrc/tldr/pages/$argv [1] -name ' *.md' ))
11
- for f in $files
12
- echo $f
13
- end
45
+ basename -s .md (find $HOME /.tldrc/tldr/pages/$argv [1] -name ' *.md' ) | string escape
14
46
end
15
47
16
48
if test -d " $HOME /.tldrc/tldr/pages"
@@ -25,7 +57,9 @@ if test -d "$HOME/.tldrc/tldr/pages"
25
57
set cmpl $cmpl (__tldr_get_files sunos)
26
58
end
27
59
28
- complete -c tldr -a ( echo $cmpl | sort | uniq )
60
+ complete -c tldr -f -a " $cmpl " -n __tldr_positional
29
61
end
30
62
63
+ complete -c tldr -f
64
+
31
65
functions -e __tldr_get_files
0 commit comments