-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for using existing Dash.app docsets #53
base: master
Are you sure you want to change the base?
Changes from 4 commits
1f9d853
a992bec
a5bac0d
83e2a6f
be94464
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,11 @@ | |
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` | ||
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`. | ||
# | ||
# `DASHT_USE_DASH_APP` | ||
# Set to "true" to use Dash.app's (MacOS only) docset library. Disables | ||
# docset management commands (install, remove, update). Also changes the | ||
# default `DASHT_DOCSETS_DIR` to "~/Library/Application Support/Dash". | ||
# | ||
# ## EXIT STATUS | ||
# | ||
# 44 | ||
|
@@ -67,11 +72,29 @@ | |
# Written in 2016 by Suraj N. Kurapati <https://github.com/sunaku/dasht> | ||
# Distributed under the terms of the ISC license (refer to README file). | ||
|
||
: ${DASHT_USE_DASH_APP:=false} | ||
if $DASHT_USE_DASH_APP; then | ||
: ${DASHT_DOCSETS_DIR:="$HOME/Library/Application Support/Dash"} | ||
else | ||
: ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
fi | ||
|
||
if test $# -gt 0; then | ||
pattern=$1 | ||
shift | ||
fi | ||
|
||
# Ensure any docsets we are accessing from the Dash.app library have had their | ||
# documents extracted. Dash.app leaves the documents in the tarball by default. | ||
if $DASHT_USE_DASH_APP; then | ||
dasht-docsets "$@" | while read docset; do | ||
root=("$DASHT_DOCSETS_DIR/"*/*"/${docset}.docset") | ||
if ! test -d "${root}/Contents/Resources/Documents"; then | ||
dasht-docsets-extract "$root/Contents/Resources/tarix.tgz" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this extraction would better fit in a different script, say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I made the requested changes and tested it out a bit, I think all is working well. BTW, you should update gitignore and instructions re manpages:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your feedback. Actually, both of those are exactly as they're meant to be:
!/man/man?/*.?
/man |
||
fi | ||
done | ||
fi | ||
|
||
count=$(dasht-docsets "$@" | wc -l) | ||
if test $count -eq 0; then | ||
# notify user when no docsets are installed so they can go install them | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,11 @@ | |
# If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` | ||
# or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`. | ||
# | ||
# `DASHT_USE_DASH_APP` | ||
# Set to "true" to use Dash.app's (MacOS only) docset library. Disables | ||
# docset management commands (install, remove, update). Also changes the | ||
# default `DASHT_DOCSETS_DIR` to "~/Library/Application Support/Dash". | ||
# | ||
# ## EXIT STATUS | ||
# | ||
# 44 | ||
|
@@ -86,7 +91,12 @@ | |
# Written in 2016 by Suraj N. Kurapati <https://github.com/sunaku/dasht> | ||
# Distributed under the terms of the ISC license (refer to README file). | ||
|
||
: ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
: ${DASHT_USE_DASH_APP:=false} | ||
if $DASHT_USE_DASH_APP; then | ||
: ${DASHT_DOCSETS_DIR:="$HOME/Library/Application Support/Dash"} | ||
else | ||
: ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
fi | ||
|
||
pattern=$(echo " $1 " | sed -e 's/[%_]/\\&/g' -e 's/[[:space:]]\{1,\}/%/g') | ||
test $# -gt 0 && shift # shift off PATTERN so argv contains solely DOCSETs | ||
|
@@ -95,7 +105,12 @@ status=44 # (default) exit with a nonzero status when no results are found | |
trap 'status=0' USR1 # override default exit status when results are found | ||
|
||
dasht-docsets "$@" | while read -r docset; do | ||
database="$DASHT_DOCSETS_DIR/$docset".docset/Contents/Resources/docSet.dsidx | ||
if $DASHT_USE_DASH_APP; then | ||
relpath=("$DASHT_DOCSETS_DIR"/*/*/"$docset".docset) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the |
||
database="$relpath/Contents/Resources/docSet.dsidx" | ||
else | ||
database="$DASHT_DOCSETS_DIR/$docset".docset/Contents/Resources/docSet.dsidx | ||
fi | ||
file_url="file://$(dirname "$database")/Documents/" | ||
|
||
dasht-query-exec "$pattern" "$database" -line | | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need
(
array)
syntax.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your comment:
Could you please try surrounding the stars with slashes (by moving them out of the surrounding strings)? Like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if BASH is requiring you to add
(
array)
syntax because the glob can potentially match more than one file, then it would be better to convert this expression into a nested loop: