0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

fish shell argparse コマンドで未定義のオプションを読み飛ばす (ignore-unknown オプション)

Posted at

fish shell の関数とfish shellの組み込み関数 argparse を組み合わせて, 既存のコマンドをラップしたコマンドを用意したいと思いました.

function checkupdates --description 'alias checkupdates=checkupdates'
    argparse --name=checkupdates 'j/json' -- $argv
    or return 1
    # 省略

オプション -j or --json だけを指定したときに限りこのラップ関数は機能しますが, 既存コマンド (checkupdates) の既存オプションを指定すると, エラーになってしまいます.

$ checkupdates -n --json
checkupdates: -n: unknown option

この場合, argparse コマンドのオプション -i or --ignore-unknown を指定することで回避できます.

argparse -i --name=checkupdates 'j/json' -- $argv

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?