Would be nice if long descriptions were handled better
未关闭
还没有人认领这个 Issue。
- 主要语言
- Ruby
- 星标
- 71
- 派生
- 27
- 平均合并
- 3 小时 3 分钟
- 30 天内合并 PR
- 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 opts.rb 显示的 OptionParser 帮助输出入手,跟踪 -h 使用的格式化路径。根据终端宽度为较长的选项描述实现换行,同时保留显示的缩进,然后验证示例输出能够整齐地换行。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ruby
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100