Return page result on first run
This commit is contained in:
parent
55a0837bf8
commit
c43af0e308
11
tldr
11
tldr
|
@ -224,10 +224,7 @@ Config(){
|
||||||
}
|
}
|
||||||
index=$cachedir/index.json
|
index=$cachedir/index.json
|
||||||
# update if the file doesn't exists, or if it's older than $TLDR_EXPIRY
|
# update if the file doesn't exists, or if it's older than $TLDR_EXPIRY
|
||||||
[[ -f $index ]] && Recent "$index" || Cache_fill 0
|
[[ -f $index ]] && Recent "$index" || Cache_fill
|
||||||
|
|
||||||
# initiate autocomplete for current session
|
|
||||||
complete -W "$(q=($cachedir/*/*); sed 's@\.md @ @g' <<<${q[@]##*/})" tldr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1: error message; Uses: md REPLY ln
|
# $1: error message; Uses: md REPLY ln
|
||||||
|
@ -374,7 +371,7 @@ Find_regex(){
|
||||||
Cache_fill(){
|
Cache_fill(){
|
||||||
local tmp unzip
|
local tmp unzip
|
||||||
unzip="$(type -p unzip) -q" || {
|
unzip="$(type -p unzip) -q" || {
|
||||||
Err "Unzip is necessary to fill the cache"
|
Err "tldr requires ${I}unzip$XI to fill the cache"
|
||||||
exit 7
|
exit 7
|
||||||
}
|
}
|
||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
|
@ -392,7 +389,6 @@ Cache_fill(){
|
||||||
mv -- "$tmp/pages/"* "${cachedir:?}/"
|
mv -- "$tmp/pages/"* "${cachedir:?}/"
|
||||||
rm -rf -- "$tmp"
|
rm -rf -- "$tmp"
|
||||||
Inf "Pages cached in $U$cachedir$XU"
|
Inf "Pages cached in $U$cachedir$XU"
|
||||||
exit "$1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# $@: commandline parameters; Uses: version cached; Sets: platform page
|
# $@: commandline parameters; Uses: version cached; Sets: platform page
|
||||||
|
@ -414,7 +410,8 @@ Main(){
|
||||||
platform=current
|
platform=current
|
||||||
List_pages $err ;;
|
List_pages $err ;;
|
||||||
-u|--update) [[ $2 ]] && Err "$nomore" && err=15
|
-u|--update) [[ $2 ]] && Err "$nomore" && err=15
|
||||||
Cache_fill "$err" ;;
|
Cache_fill
|
||||||
|
exit "$err" ;;
|
||||||
-v|--version) [[ $2 ]] && Err "$nomore" && err=16
|
-v|--version) [[ $2 ]] && Err "$nomore" && err=16
|
||||||
Inf "$version"
|
Inf "$version"
|
||||||
exit "$err" ;;
|
exit "$err" ;;
|
||||||
|
|
Loading…
Reference in New Issue