@@ -275,12 +275,12 @@ _参考文献: [The Anti-Mac User Interface (Don Gentner and Jakob Nielsen)](htt
275
275
* Julia: [ ArgParse.jl] ( https://github.com/carlobaldassi/ArgParse.jl ) , [ Comonicon.jl] ( https://github.com/comonicon/Comonicon.jl )
276
276
* Kotlin: [ clikt] ( https://ajalt.github.io/clikt/ )
277
277
* Node: [ oclif] ( https://oclif.io/ )
278
- * Deno: [ flags ] ( https://deno.land/ std/flags )
278
+ * Deno: [ parseArgs ] ( https://jsr.io/@ std/cli/doc/parse-args/~/parseArgs )
279
279
* Perl: [ Getopt::Long] ( https://metacpan.org/pod/Getopt::Long )
280
280
* PHP: [ console] ( https://github.com/symfony/console ) , [ CLImate] ( https://climate.thephpleague.com )
281
281
* Python: [ Argparse] ( https://docs.python.org/3/library/argparse.html ) , [ Click] ( https://click.palletsprojects.com/ ) , [ Typer] ( https://github.com/tiangolo/typer )
282
282
* Ruby: [ TTY] ( https://ttytoolkit.org/ )
283
- * Rust: [ clap] ( https://clap .rs/ )
283
+ * Rust: [ clap] ( https://docs .rs/clap )
284
284
* Swift: [ swift-argument-parser] ( https://github.com/apple/swift-argument-parser )
285
285
286
286
** 成功時は終了コードゼロ、失敗時には非ゼロを返してください。**
@@ -299,9 +299,17 @@ _参考文献: [The Anti-Mac User Interface (Don Gentner and Jakob Nielsen)](htt
299
299
300
300
** なにもオプションを指定しなかった時、` -h ` や` --help ` フラグが指定された時にはヘルプテキストを表示してください。**
301
301
302
+ <<<<<<< HEAD
302
303
** デフォルトでは簡潔なヘルプテキストを出力するようにしてください。**
303
304
可能なら、` myapp ` や` myapp subcommand ` が実行された時はデフォルトでヘルプテキストを表示するようにしてください。
304
305
プログラムが非常にシンプルで明らかなデフォルトの動作があるとき (例: ` ls ` ) や、プログラムが入力をインタラクティブに受け取る時 (例: ` cat ` ) はその限りではありません。
306
+ =======
307
+ ** Display a concise help text by default.**
308
+ When ` myapp ` or ` myapp subcommand ` is run with no arguments, display help text.
309
+
310
+ You can ignore this guideline if your program or subcommand is very simple and requires no arguments (e.g. ` ls ` , ` git pull ` ),
311
+ or if it's interactive by default (e.g. ` npm init ` ).
312
+ >>>>>>> upstream/main
305
313
306
314
簡潔なヘルプテキストは以下のもののみを含むべきです。
307
315
@@ -543,8 +551,13 @@ _TTYが何かについては[参考文献を読んでください。](https://un
543
551
このテキストストリームは通常スクリプトを書くために使われますが、プログラムを使う人間のユーザビリティにも役立ちます。
544
552
たとえば、` grep ` に出力を流して期待する出力を得ることがあります。
545
553
554
+ <<<<<<< HEAD
546
555
> “すべてのプログラムの出力は、未知のものも含めた他のプログラムの入力となることを期待する。”
547
556
— [ Doug McIlroy] ( https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html )
557
+ =======
558
+ > “Expect the output of every program to become the input to another, as yet unknown, program.”
559
+ — [ Doug McIlroy] ( http://web.archive.org/web/20220609080931/https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html )
560
+ >>>>>>> upstream/main
548
561
549
562
** 人間可読な出力が機械可読な出力を壊す場合、` --plain ` で出力を平易な、` grep ` や` awk ` のようなツールと統合できる表形式のテキストフォーマットにするようにしてください。**
550
563
場合によっては、人間にとって読みやすいのとは異なる方法で出力を行う必要があるかもしれません。
@@ -638,12 +651,21 @@ drwxr-xr-x 2 root root 4.0K Jul 20 14:57 skel
638
651
** プログラムがターミナルで動作していない、もしくはユーザが無効化するよう要請した時は、色を無効化してください。**
639
652
以下のようなもので色を無効化できるべきです。
640
653
654
+ <<<<<<< HEAD
641
655
- ` stdout ` や` stderr ` がインタラクティブなターミナル (TTY) ではない。
642
656
この2つは個別にチェックするのが最良です。` stdout ` を他のプログラムにパイプ接続しているときでも、` stderr ` に色がついていると便利です。
643
657
- ` NO_COLOR ` 環境変数が設定されている。
644
658
- ` TERM ` 環境変数の値が` dumb ` である。
645
659
- ユーザが` --no-color ` オプションを渡した。
646
660
- 特にあなたのプログラムだけ色を無効化したいという場合は` MYAPP_NO_COLOR ` 環境変数を追加したくなるかもしれません。
661
+ =======
662
+ - ` stdout ` or ` stderr ` is not an interactive terminal (a TTY).
663
+ It’s best to individually check—if you’re piping ` stdout ` to another program, it’s still useful to get colors on ` stderr ` .
664
+ - The ` NO_COLOR ` environment variable is set and it is not empty (regardless of its value).
665
+ - The ` TERM ` environment variable has the value ` dumb ` .
666
+ - The user passes the option ` --no-color ` .
667
+ - You may also want to add a ` MYAPP_NO_COLOR ` environment variable in case users want to disable color specifically for your program.
668
+ >>>>>>> upstream/main
647
669
648
670
_ 参考文献: [ no-color.org] ( https://no-color.org/ ) , [ 12 Factor CLI Apps] ( https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46 ) _
649
671
@@ -685,10 +707,17 @@ UwlHnUFXgENO3ifPZd8zoSKMxESxxot4tMgvfXjmRp5G3BGrAnonncE7Aj11pn3SSYgEcrrn2sMyLGpV
685
707
** 少なくともデフォルトでは` stderr ` をログファイルのように扱わないでください。**
686
708
verboseモードでない時にログレベルのラベル (` ERR ` 、` WARN ` 等) や関連性の薄い情報を出力しないでください。
687
709
710
+ <<<<<<< HEAD
688
711
** 大量のテキストを出力する時はページャ (例: ` less ` ) を使ってください。**
689
712
たとえば、` git diff ` はデフォルトでこれを行います。
690
713
ページャの使用は問題を起こしやすいので、ユーザの体験を損なわないように実装には気をつけてください。
691
714
` stdin ` や` stdout ` がインタラクティブなターミナルでないならページャを使うべきではありません。
715
+ =======
716
+ ** Use a pager (e.g. ` less ` ) if you are outputting a lot of text.**
717
+ For example, ` git diff ` does this by default.
718
+ Using a pager can be error-prone, so be careful with your implementation such that you don’t make the experience worse for the user.
719
+ Use a pager only if ` stdin ` or ` stdout ` is an interactive terminal.
720
+ >>>>>>> upstream/main
692
721
693
722
` less ` に対する優れたオプション指定は` less -FIRX ` です。
694
723
これによってコンテンツがスクリーンに収まる場合は動作せず、検索の際に大文字・小文字を無視し、色と書式を有効化し、` less ` が終了した時に画面にコンテンツを残すようになります。
@@ -845,6 +874,7 @@ unknown flag: --foo
845
874
これはユーザを混乱させるかもしれません。コマンドの使用においてそのような混乱が起こる最も一般的な動作は、上キーを押して直近の呼び出しを取り出して、末尾にオプションを追加してまた実行するような場面です。
846
875
可能ならば、引数パーサの制約にぶつかったとしても、どちらの形式も等価であるようにしてください。
847
876
877
+ <<<<<<< HEAD
848
878
** シークレットをフラグから直接読まないでください。**
849
879
` --password ` のような形でコマンドがシークレットを受け取るとき、引数の値は` ps ` の出力や場合によりシェルの履歴等から漏洩します。
850
880
さらに、この手のフラグはシークレットに対するセキュアでない環境変数の使用を招きます。
@@ -855,6 +885,20 @@ unknown flag: --foo
855
885
(Bashでは` --password $(< password.txt) ` のようにファイルの内容を渡すことが可能です。
856
886
このアプローチは` ps ` の出力によってファイルの中身が漏洩する同じようなセキュリティリスクがあります。
857
887
避けるべきです。)
888
+ =======
889
+ ** Do not read secrets directly from flags.**
890
+ When a command accepts a secret, e.g. via a ` --password ` flag,
891
+ the flag value will leak the secret into ` ps ` output and potentially shell history.
892
+ And, this sort of flag encourages the use of insecure environment variables for secrets.
893
+ (Environment variables are insecure because they can often be read by other users, their values end up in debug logs, etc.)
894
+
895
+ Consider accepting sensitive data only via files, e.g. with a ` --password-file ` flag, or via ` stdin ` .
896
+ A ` --password-file ` flag allows a secret to be passed in discreetly, in a wide variety of contexts.
897
+
898
+ (It’s possible to pass a file’s contents into a flag in Bash by using ` --password $(< password.txt) ` .
899
+ This approach has the same security as mentioned above.
900
+ It’s best avoided.)
901
+ >>>>>>> upstream/main
858
902
859
903
### インタラクティブ性 {#interactivity}
860
904
@@ -1091,11 +1135,19 @@ XDGベースディレクトリ仕様
1091
1135
** 設定パラメータを優先順位に従って適用してください。**
1092
1136
以下は設定パラメータの優先順位を高いものから順に並べたものです。
1093
1137
1138
+ <<<<<<< HEAD
1094
1139
- フラグ
1095
1140
- 実行中のシェルの環境変数
1096
1141
- プロジェクトレベルの設定 (例: ` .env ` )
1097
1142
- ユーザレベル設定
1098
1143
- システムレベル設定
1144
+ =======
1145
+ - Flags
1146
+ - The running shell’s environment variables
1147
+ - Project-level configuration (e.g. ` .env ` )
1148
+ - User-level configuration
1149
+ - System wide configuration
1150
+ >>>>>>> upstream/main
1099
1151
1100
1152
### 環境変数 {#environment-variables}
1101
1153
0 commit comments