Would be nice if long descriptions were handled better
オープン
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 71
- フォーク
- 27
- 平均マージ
- 3時間 3分
- マージ済み PR(30日)
- 2
説明
Consider:
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]"
opts.on('-d', '--do-thing', 'Do a thing') do
options[:do] = true
end
opts.on('-l', '--long-option', 'Here\'s an option with a pretty long description in order to see what OptionParser does with options with pretty long descriptions when the pretty long description is pretty long.') do
options[:long] = l
end
opts.on('-s COUNT', '--do-some-more-things=COUNT', 'Do some more things') do |count|
options[:more] = count
end
end.parse!
p options
p ARGV
Then:
$ ruby opts.rb -h
Usage: opts.rb [options]
-d, --do-thing Do a thing
-l, --long-option Here's an option with a pretty long description in order to see what OptionParser does with opt
ions with pretty long descriptions when the pretty long description is pretty long.
-s, --do-some-more-things=COUNT Do some more things
(I purposely wrapped it as I’d see it in a 132 column terminal window.)
It would be nice if OptionParser handled that better, getting the current terminal width and wrapping the description intelligently:
Usage: opts.rb [options]
-d, --do-thing Do a thing
-l, --long-option Here's an option with a pretty long description in order to see what OptionParser does with
options with pretty long descriptions when the pretty long description is pretty long.
-s, --do-some-more-things=COUNT Do some more things
I often write descriptions that would wrap in a 132 (or even more in an 80) column terminal window. When I manually write usages I handle that, but being OptionParser handles usage for me (very handy!) it would be nice if it did too.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
opts.rb に表示される OptionParser のヘルプ出力から始め、-h で使用されるフォーマット処理の経路を追跡します。表示されるインデントを維持しながら、端末の幅に基づいて長いオプション説明を折り返す処理を実装し、その後、例の出力がきれいに折り返されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ruby
- 領域
- cli
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100