Would be nice if long descriptions were handled better
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 71
- Forks
- 27
- Ø Merge
- 3 Std. 3 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei der für opts.rb angezeigten OptionParser-Hilfeausgabe und verfolge den für -h verwendeten Formatierungspfad. Implementiere den Zeilenumbruch für lange Optionsbeschreibungen anhand der Terminalbreite, wobei die angezeigte Einrückung erhalten bleibt, und überprüfe anschließend, dass die Beispielausgabe sauber umgebrochen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100