argparse - argparse - fishのスクリプトや関数に渡されるオプションの解析
このコマンドはfishのスクリプトや関数が,fishのビルトイン関数が引数を扱うのと100%同じ方法で引数を取り扱うのを簡単にします.
ユーザは有効なオプションを定義する引数の組を渡し,リテラル--
を続け,その後に解析される引数(リテラル--
を含んでもよい)を渡します.
これに関する詳細は以下の「使い方」の節で述べます.
julia = (-0.754567,-0.209658) | |
# julia = (-0.3, -0.63) | |
# julia = (0.285, 0.01) | |
def setup(): | |
size(400,400, P2D) | |
pixelDensity(displayDensity()) | |
frameRate(50) | |
print julia |
def setup(): | |
size(*[360]*2) | |
global A, B, C, h | |
h = 180 | |
A = [[random(-1, 1) for _ in range(3)] for _ in range(3)] | |
B = [[random(-1,1) for _ in range(3)] for _ in range(3)] | |
C = [[random(-1,1) for _ in range(3)] for _ in range(3)] |
# Defined in /Users/Ryota/.config/fish/functions/volt.fish @ line 2 | |
function volt | |
set -q VOLTPATH | |
and set -l voltpath $VOLTPATH | |
or set -l voltpath "$HOME/volt" | |
switch "$argv[1]" | |
case "" | |
volt repo | |
case up |
# Defined in /Users/Ryota/.config/fish/functions/funcgist.fish @ line 1 | |
function funcgist | |
if not type -q gist | |
echo "funcgist: command 'gist' is required" >&2 | |
end | |
argparse -n funcgist 'h/help' 'd/description=' -- $argv | |
or return 1 | |
if set -q _flag_h |
p is a function with definition | |
# Defined in /Users/Ryota/.config/fish/functions/p.fish @ line 1 | |
function p --no-scope-shadowing | |
# | |
# use any variables except for `argv` | |
# | |
if set -q argv[1] | |
set_color red | |
if test $argv[1] = argv | |
set -e argv |
def is a function with definition | |
# Defined in /Users/Ryota/.config/fish/functions/def.fish @ line 2 | |
function def --description 'manage fish functions/complitons' | |
# --help option: show usage and exit | |
function __def_usage | |
echo "NAME: def - Manage your local function definitions" | |
echo | |
echo "USAGE: def [options] function-names..." | |
echo | |
echo "OPTIONS:" |
function addb | |
while read -l line | |
echo $line | |
end | |
if count $argv >/dev/null | |
echo $argv[1] | |
end | |
end |
function help-ja --description 'Show Japanese help for the fish shell' | |
set -l topics (builtin -n) tutorial document-ja faq-ja design-document-ja | |
set -l home 'http://fish.rubikitch.com' | |
switch "$argv[1]" | |
case -h --h --he --hel --help | |
echo 'Usage: help-ja [TOPIC]' | |
case $topics | |
open "$home/$argv[1]" | |
case '*' |
" 80文字範囲外塗りつぶしのオンオフ | |
function! s:ToggleMargin() | |
let value = &colorcolumn | |
if strlen(value) | |
set colorcolumn="" | |
set colorcolumn? | |
else | |
execute "set colorcolumn=".join(range(&textwidth+1, 999), ',') | |
echo " colorcolumn=81..." | |
endif |