mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-23 01:11:55 +08:00
change cli and create omf.remote from get_all_repos
This commit is contained in:
parent
6d9bb3c2db
commit
0072934733
@ -8,7 +8,11 @@ function omf -d "Oh My Fish helper"
|
|||||||
if test (count $argv) -gt 0
|
if test (count $argv) -gt 0
|
||||||
switch $argv[1]
|
switch $argv[1]
|
||||||
case 'install'
|
case 'install'
|
||||||
omf.packages --install
|
if test (count $argv) -gt 2
|
||||||
|
omf.packages --install $argv[2] $argv[3]
|
||||||
|
else
|
||||||
|
omf.packages --install
|
||||||
|
end
|
||||||
case 'update'
|
case 'update'
|
||||||
omf.packages --update
|
omf.packages --update
|
||||||
case 'list' 'ls'
|
case 'list' 'ls'
|
||||||
@ -19,14 +23,10 @@ function omf -d "Oh My Fish helper"
|
|||||||
if [ $status -eq 0 ]
|
if [ $status -eq 0 ]
|
||||||
omf.log 'green' 'Oh My Fish has been successfully updated.'
|
omf.log 'green' 'Oh My Fish has been successfully updated.'
|
||||||
end
|
end
|
||||||
case 'available-plugins'
|
case 'plugins'
|
||||||
omf.packages --available-plugins
|
omf.packages --plugins
|
||||||
case 'available-themes'
|
case 'themes'
|
||||||
omf.packages --available-themes
|
omf.packages --themes
|
||||||
case 'download-plugin'
|
|
||||||
omf.packages --download-plugin $argv[2]
|
|
||||||
case 'download-theme'
|
|
||||||
omf.packages --download-theme $argv[2]
|
|
||||||
case '*'
|
case '*'
|
||||||
omf.helper
|
omf.helper
|
||||||
end
|
end
|
||||||
|
@ -10,12 +10,9 @@ function omf.helper -d 'Prints all functions supported by Oh My Fish helper'
|
|||||||
omf.log normal ''
|
omf.log normal ''
|
||||||
omf.log normal ' Examples:'
|
omf.log normal ' Examples:'
|
||||||
omf.log normal ' omf install'
|
omf.log normal ' omf install'
|
||||||
|
omf.log normal ' omf install --plugin|--theme NAME'
|
||||||
omf.log normal ' omf update'
|
omf.log normal ' omf update'
|
||||||
omf.log normal ' omf list'
|
omf.log normal ' omf list'
|
||||||
omf.log normal ' omf self-update'
|
omf.log normal ' omf self-update'
|
||||||
omf.log normal ' omf available-plugins'
|
|
||||||
omf.log normal ' omf available-themes'
|
|
||||||
omf.log normal ' omf download-plugin'
|
|
||||||
omf.log normal ' omf download-theme'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,36 +7,41 @@
|
|||||||
# OPTIONS
|
# OPTIONS
|
||||||
# --install
|
# --install
|
||||||
# Install all packages
|
# Install all packages
|
||||||
|
# --install --plugin|--theme NAME
|
||||||
|
# Install one theme/plugin
|
||||||
# --update
|
# --update
|
||||||
# Update all packages
|
# Update all packages
|
||||||
# --list
|
# --list
|
||||||
# List all active packages
|
# List all active packages
|
||||||
# --available-plugins
|
# --plugins
|
||||||
# List all plugins available from the oh-my-fish Github repository
|
# List all plugins available from the oh-my-fish Github repository
|
||||||
# --available-themes
|
# --themes
|
||||||
# List all themes available from the oh-my-fish Github repository
|
# List all themes available from the oh-my-fish Github repository
|
||||||
# --download-plugin [PLUGIN]
|
|
||||||
# Download and install PLUGIN
|
|
||||||
# --download-theme [THEME]
|
|
||||||
# Download and install THEME
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Manage all plugins and themes specified on the $fish_plugins
|
# Manage all plugins and themes specified on the $fish_plugins
|
||||||
# and $fish_theme variables
|
# and $fish_theme variables
|
||||||
#
|
#
|
||||||
function omf.packages --argument-names options arg -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
|
set -g __omf_packages_modified 0
|
||||||
|
|
||||||
switch $options
|
switch $options
|
||||||
case '--install'
|
case '--install'
|
||||||
for plugin in $fish_plugins
|
switch "$arg1"
|
||||||
omf.packages.install --plugin $plugin
|
case '--plugin'
|
||||||
end
|
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 ]
|
if [ $__omf_packages_modified -eq 0 ]
|
||||||
omf.log green 'All packages were already installed.'
|
omf.log green 'All packages were already installed.'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
case '--update'
|
case '--update'
|
||||||
for plugin in $fish_plugins
|
for plugin in $fish_plugins
|
||||||
@ -59,33 +64,15 @@ function omf.packages --argument-names options arg -d 'Manage all plugins and th
|
|||||||
if test -n "$fish_theme"
|
if test -n "$fish_theme"
|
||||||
omf.log normal $fish_theme
|
omf.log normal $fish_theme
|
||||||
end
|
end
|
||||||
case '--available-plugins'
|
case '--plugins'
|
||||||
get_all_repos | grep "plugin-" | cut -d "-" -f 2- | sort | paste -sd ' ' -
|
omf.remote --plugins | paste -sd ' ' -
|
||||||
case '--available-themes'
|
case '--themes'
|
||||||
get_all_repos | grep "theme-" | cut -d "-" -f 2- | sort | paste -sd ' ' -
|
omf.remote --themes | paste -sd ' ' -
|
||||||
case '--download-plugin'
|
|
||||||
omf.packages.install --plugin $arg
|
|
||||||
case '--download-theme'
|
|
||||||
omf.packages.install --theme $arg
|
|
||||||
case '*'
|
case '*'
|
||||||
omf.log red 'Unknown option'
|
omf.log red 'Unknown option'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_all_repos
|
|
||||||
set url "https://api.github.com/orgs/oh-my-fish/repos"
|
|
||||||
set page_count (curl -sI "$url?page=1&per_page=100" | sed -nr 's/^Link:.*page=([0-9]+)&per_page=100>; rel="last".*/\1/p')
|
|
||||||
|
|
||||||
if echo $page_count | grep -vE '^[0-9]+$'
|
|
||||||
echo "Could not access Github API" >&2
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
|
|
||||||
for i in (seq $page_count)
|
|
||||||
curl -s "$url?page=$i&per_page=100" | grep \"name\" | tr \": " " | awk '{print $2}'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function omf.packages.report.installing -e omf_package_installing
|
function omf.packages.report.installing -e omf_package_installing
|
||||||
omf.log -n white "Installing $argv... "
|
omf.log -n white "Installing $argv... "
|
||||||
end
|
end
|
||||||
|
39
plugins/omf/omf.remote.fish
Normal file
39
plugins/omf/omf.remote.fish
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 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" | sed -nr 's/^Link:.*page=([0-9]+)&per_page=100>; rel="last".*/\1/p')
|
||||||
|
|
||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user