mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-15 20:03:16 +08:00
![Stephen M. Coakley](/assets/img/avatar_default.png)
Replace package database with independently installed package repositories - Add support for fetching and installing from package repositories containing package URLs and metadata - Support multiple package repository sources - Add new repo command - Remove submit command - Enhance describe and search commands - Fix and improve help text for new and adjusted commands - Fix bundle install exit status - Refer to plugins as "plugins" instead of the general term "packages" - Code clarity improvements - Put plugin/theme distinction into package metadata
65 lines
1.5 KiB
Fish
65 lines
1.5 KiB
Fish
function omf.index.stat -a name -d 'Get package properties'
|
|
if test -z "$name"
|
|
return 1
|
|
end
|
|
|
|
set -e argv[1]
|
|
set -l properties $argv
|
|
set -l package_file
|
|
|
|
# Find the package definition file.
|
|
set -l package_files (omf.index.path)/*/packages/$name
|
|
|
|
if set -q package_files[1]
|
|
set package_file $package_files[1]
|
|
else
|
|
return 1
|
|
end
|
|
|
|
# If no properties are specified, output all properties with names.
|
|
if not set -q properties[1]
|
|
command cat $package_file
|
|
return
|
|
end
|
|
|
|
# Find only the values of the properties requested.
|
|
command awk '
|
|
BEGIN {
|
|
FS = "[ \t]*=[ \t]*";
|
|
|
|
# Set default values for certain properties.
|
|
defaults["type"] = "plugin";
|
|
|
|
# Get the list of properties to display.
|
|
for (i = 2; i < ARGC; i++) {
|
|
properties[i - 1] = ARGV[i];
|
|
delete ARGV[i];
|
|
count++;
|
|
}
|
|
}
|
|
|
|
!/^#/ {
|
|
# Store the property value.
|
|
values[$1] = $2;
|
|
}
|
|
|
|
END {
|
|
# Print out each requested property.
|
|
for (i = 1; i <= count; i++) {
|
|
property = properties[i];
|
|
|
|
if (property in values) {
|
|
# If the property was set, print it out.
|
|
print values[property];
|
|
} else if (property in defaults) {
|
|
# If the property was not set and has a default value, print it out.
|
|
print defaults[property];
|
|
} else {
|
|
# Print a blank line if the property was not found.
|
|
print "";
|
|
}
|
|
}
|
|
}
|
|
' - $properties < $package_file
|
|
end
|