kurusugawa-computer / kurusugawa-computer/annofab-cli
[helpオプション] `--`から始まる必須の引数は、"optional arguments"グループに表示させない
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 51m
- Merged PRs (30d)
- 12
Description
現状
--から始まる必須の引数は、必須なのに"optional arguments"というグループに表示されます。
これは間違った表現なので、適切な表現にしたいです。
$ annofabcli task list -h
usage: annofabcli task list [-h] [--yes] [--endpoint_url ENDPOINT_URL] [--logdir LOGDIR] [--disable_log] [--debug] -p PROJECT_ID [-tq TASK_QUERY | -t TASK_ID [TASK_ID ...]] [-u USER_ID [USER_ID ...]] [-f {csv,json,pretty_json,task_id_list}] [-o OUTPUT] [--csv_format CSV_FORMAT] [-q QUERY]
タスク一覧を出力します。
options:
-p PROJECT_ID, --project_id PROJECT_ID
対象のプロジェクトのproject_idを指定します。 (required)
-tq TASK_QUERY, --task_query TASK_QUERY
タスクの検索クエリをJSON形式で指定します。指定しない場合は、すべてのタスクを取得します。 ``file://`` を先頭に付けると、JSON形式のファイルを指定できます。クエリのフォーマットは、`getTasks <https://annofab.com/docs/api/#operation/getTasks>`_ APIのクエリパラメータと同じです。さらに追加で、``user_id`` , ``previous_user_id`` キーも指定できます。ただし ``page`` , ``limit`` キーは指定できません。
-t TASK_ID [TASK_ID ...], --task_id TASK_ID [TASK_ID ...]
対象のタスクのtask_idを指定します。 ``--task_query`` 引数とは同時に指定できません。 ``file://`` を先頭に付けると、task_idの一覧が記載されたファイルを指定できます。
-u USER_ID [USER_ID ...], --user_id USER_ID [USER_ID ...]
絞り込み対象である担当者のuser_idを指定します。 ``file://`` を先頭に付けると、task_idの一覧が記載されたファイルを指定できます。
-f {csv,json,pretty_json,task_id_list}, --format {csv,json,pretty_json,task_id_list}
出力フォーマットを指定します。指定しない場合は、csv フォーマットになります。 (default: csv)
-o OUTPUT, --output OUTPUT
出力先のファイルパスを指定します。指定しない場合は、標準出力に出力されます。
--csv_format CSV_FORMAT
CSVのフォーマットをJSON形式で指定します。 ``--format`` が ``csv`` でないときは、このオプションは無視されます。 ``file://`` を先頭に付けると、JSON形式のファイルを指定できます。指定した値は、`pandas.DataFrame.to_csv <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html>`_ の引数として渡されます。
-q QUERY, --query QUERY
JMESPath形式で指定します。出力結果の抽出や、出力内容の変更に利用できます。
対応方法
必須の引数は、"required arguments"という引数グループに格納したいです。
$ annofabcli task list -h
タスク一覧を出力します。
required arguments:
-p PROJECT_ID, --project_id PROJECT_ID
options:
-tq TASK_QUERY, --task_query TASK_QUERY
-t TASK_ID [TASK_ID ...], --task_id TASK_ID [TASK_ID ...]
-u USER_ID [USER_ID ...], --user_id USER_ID [USER_ID ...]
-f {csv,json,pretty_json,task_id_list}, --format {csv,json,pretty_json,task_id_list}
-o OUTPUT, --output OUTPUT
--csv_format CSV_FORMAT
-q QUERY, --query QUERY
懸念事項
add_mutually_exclusive_groupでrequiredが指定されたとき、どの引数グループに入れるべきなのか?
https://docs.python.org/ja/3.7/library/argparse.html#mutual-exclusion
たぶんoptionsに入れるのがよさそう。
参考
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the argparse setup used by the annofabcli task list command and inspect how required arguments are assigned to help groups, including the add_mutually_exclusive_group case. The change is done when required options appear under a required arguments group while mutually exclusive required options retain the intended grouping, and the resulting -h output matches the issue's examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100