oh-my-fish/pkg/omf/cli/omf.packages.list.fish

73 lines
1.8 KiB
Fish
Raw Normal View History

2015-10-07 04:31:44 +08:00
function __omf.packages.sort
for package in (echo $argv | tr ' ' '\n' | sort); echo $package; end
end
function __omf.packages.list -a type
set -l list
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/pkg/*)
set list $list $package
end
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/themes/*)
set list $list $package
end
__omf.packages.sort $list
end
function __omf.packages.list.available -a type
set -l list
test "$type" = "--theme"; or for package in (basename $OMF_PATH/db/pkg/*)
contains $package (basename {$OMF_CONFIG,$OMF_PATH}/pkg/*); or set list $list $package
end
test "$type" = "--plugin"; or for package in (basename $OMF_PATH/db/themes/*)
contains $package (basename {$OMF_CONFIG,$OMF_PATH}/themes/*); or set list $list $package
end
__omf.packages.sort $list
end
function __omf.packages.list.database -a type
set -l list
test "$type" = "--theme"; or for package in (basename $OMF_PATH/db/pkg/*)
set list $list $package
end
test "$type" = "--plugin"; or for package in (basename $OMF_PATH/db/themes/*)
set list $list $package
end
__omf.packages.sort $list
end
function __omf.packages.list.installed -a type
set -l list
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/pkg/*)
set list $list $package
end
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/themes/*)
set list $list $package
end
__omf.packages.sort $list
end
function omf.packages.list -a option type
switch "$option"
case "--available"
__omf.packages.list.available $type
case "--database"
__omf.packages.list.database $type
case "--installed"
__omf.packages.list.installed $type
case "*"
__omf.packages.list $type
end
end