Commit 1c3618b1 authored by Bruno's avatar Bruno

Merge pull request #503 from farao/master

Add omf commands for listing available plugins/themes and for downloading a plugin/theme
parents 193ac424 08034598
......@@ -19,6 +19,10 @@ function omf -d "Oh My Fish helper"
if [ $status -eq 0 ]
omf.log 'green' 'Oh My Fish has been successfully updated.'
end
case 'plugins'
omf.packages --plugins
case 'themes'
omf.packages --themes
case '*'
omf.helper
end
......
......@@ -13,5 +13,6 @@ function omf.helper -d 'Prints all functions supported by Oh My Fish helper'
omf.log normal ' omf update'
omf.log normal ' omf list'
omf.log normal ' omf self-update'
omf.log normal ' omf plugins'
omf.log normal ' omf themes'
end
......@@ -7,28 +7,41 @@
# OPTIONS
# --install
# Install all packages
# --install --plugin|--theme NAME
# Install one theme/plugin
# --update
# Update all packages
# --list
# List all active packages
# --plugins
# List all plugins available from the oh-my-fish Github repository
# --themes
# List all themes available from the oh-my-fish Github repository
#
# DESCRIPTION
# Manage all plugins and themes specified on the $fish_plugins
# and $fish_theme variables
#
function omf.packages --argument-names options -d 'Manage all plugins and themes'
function omf.packages --argument-names options arg1 arg2 -d 'Manage all plugins and themes'
set -g __omf_packages_modified 0
switch $options
case '--install'
for plugin in $fish_plugins
omf.packages.install --plugin $plugin
end
switch "$arg1"
case '--plugin'
omf.packages.install --plugin $arg2
case '--theme'
omf.packages.install --theme $arg2
case ""
for plugin in $fish_plugins
omf.packages.install --plugin $plugin
end
omf.packages.install --theme $fish_theme
omf.packages.install --theme $fish_theme
if [ $__omf_packages_modified -eq 0 ]
omf.log green 'All packages were already installed.'
if [ $__omf_packages_modified -eq 0 ]
omf.log green 'All packages were already installed.'
end
end
case '--update'
for plugin in $fish_plugins
......@@ -51,6 +64,10 @@ function omf.packages --argument-names options -d 'Manage all plugins and themes
if test -n "$fish_theme"
omf.log normal $fish_theme
end
case '--plugins'
omf.remote --plugins
case '--themes'
omf.remote --themes
case '*'
omf.log red 'Unknown option'
end
......
# NAME
# omf.remote - List remote plugins and themes
#
# SYNOPSIS
# omf.remote [OPTIONS]
#
# OPTIONS
# --plugins
# List all available plugins
# --themes
# List all available themes
#
# DESCRIPTION
# List remote plugins and themes from the oh-my-fish Github repository
#
function omf.remote --argument-names options -d 'List remote plugins and themes'
set url "https://api.github.com/orgs/oh-my-fish/repos"
set page_count (curl -sI "$url?page=1&per_page=100" | grep "^Link" | sed 's/Link:.*page=\([0-9]*\)&per_page=100>; rel="last".*/\1/')
if echo $page_count | grep -vE '^[0-9]+$'
echo "Could not access Github API" >&2
exit 1
end
set repos ""
for i in (seq $page_count)
set answer (curl -s "$url?page=$i&per_page=100" | grep \"name\" | tr \": " " | awk '{print $2}')
set repos "$answer $repos"
end
switch $options
case '--plugins'
echo $repos | tr ' ' "\\n" | grep "plugin-" | cut -d "-" -f 2- | sort | paste -sd " " -
case '--themes'
echo $repos | tr ' ' "\\n" | grep "theme-" | cut -d "-" -f 2- | sort | paste -sd " " -
case '*'
omf.log red 'Unknown option'
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment