1
0
Fork 0
mirror of https://github.com/zplug/zplug synced 2024-06-03 13:26:10 +02:00
zplug/autoload/commands/__status__
b4b4r07 e50de98337 Add some new options to list command
- Organize internal specifications
- Add --loaded option to list loaded packages
- Add --installed option to list installed packages

`list` command only lists the contents of $zplugs array.
These options were necessary to list packages such as installed.
2016-12-26 21:02:59 +09:00

88 lines
2.2 KiB
Bash

#!/usr/bin/env zsh
# Description:
# Check if the remote repositories are up to date
local state arg repo
local -A repo_pids proc_states hook_build hook_finished hook_pids status_codes
local -A tags
local -F SECONDS=0
local -a repos
while (( $# > 0 ))
do
arg="$1"
case "$arg" in
--select)
zstyle ':zplug:core:status' 'select' yes
;;
-*|--*)
__zplug::core::options::unknown "$arg"
return $status
;;
"")
# Invalid
return 1
;;
*/*)
repos+=( "${arg:gs:@::}" )
;;
*)
return 1
;;
esac
shift
done
if ! __zplug::job::parallel::init "$repos[@]"; then
# Since the initialization has failed, this command is terminated.
# The error message etc. should be done within that function.
return 1
fi
repos=( "$reply[@]" )
for repo in "${repos[@]}"
do
# Run in parallel
{
__zplug::core::tags::parse "$repo"
tags=( "${reply[@]}" )
if [[ -d $tags[dir] ]]; then
# Get the package status in subprocess
# Change the directory to get the remote status
__zplug::utils::shell::cd "$tags[dir]"
case "$tags[from]" in
"local")
status_code=$_zplug_status[skip_local]
;;
"gh-r")
__zplug::utils::releases::get_state "$tags[name]" "$tags[dir]"
status_code=$status
;;
*)
__zplug::utils::git::get_state "$tags[name]" "$tags[dir]"
status_code=$status
;;
esac
else
status_code=$_zplug_status[repo_not_found]
fi
# Manage the status codes in a file
# to lock the file in order to write asynchronously
__zplug::job::handle::flock \
"$_zplug_log[status]" \
"repo:$repo\tstatus:$status_code"
} &
repo_pids[$repo]=$(builtin printf $!) # for zsh 5.3
proc_states[$repo]="created"
status_codes[$repo]=""
__zplug::job::handle::wait
done
__zplug::job::handle::elapsed_time $SECONDS
__zplug::job::parallel::deinit