mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-09 13:10:40 +00:00
63fd25dacb
+ Add documentation and examples. + Add new functions to interact with the framework: + spec.eval - eval a function by name and echo its description field + spec.functions - prints functions currently in scope that match the key glob + spec.log - log a message / test result + spec.run - run suite of tests + Rename list.erase to erase.
35 lines
1.0 KiB
Fish
35 lines
1.0 KiB
Fish
# NAME
|
|
# list.erase - erase any items from one or more lists
|
|
#
|
|
# SYNOPSIS
|
|
# <item> [<item>...] [--from] <list>
|
|
# <item> [<item>...] --from <list1> [<list2>...]
|
|
#
|
|
# DESCRIPTION
|
|
# Erase any number of items from any number of lists. If more than one
|
|
# list is specified it must be separated from the items with --from.
|
|
#
|
|
# NOTES
|
|
# While items are basically any valid sequence of symbols, lists refer
|
|
# to any global variable or local variable in the scope of the calling
|
|
# function by name.
|
|
#/
|
|
function -S list.erase
|
|
# List to erase from is at last index by default.
|
|
set -l items $argv[1..-2]
|
|
set -l lists $argv[-1]
|
|
if set -l index (contains -i -- --from $argv)
|
|
# Everything before --from are items to erase and everything
|
|
# after, lists to erase any found items from.
|
|
set items $argv[1..(math $index-1)]
|
|
set lists $argv[(math $index+1)..-1]
|
|
end
|
|
for item in $items
|
|
for list in $lists
|
|
if set -l index (contains -i -- $item $$list)
|
|
set -e $list[1][$index]
|
|
end
|
|
end
|
|
end
|
|
end
|