Would be nice if long descriptions were handled better
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 71
- Fork
- 27
- Merge medio
- 3h 3m
- PR unite (30g)
- 2
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dall’output dell’help di OptionParser mostrato per opts.rb e traccia il percorso di formattazione utilizzato da -h. Implementa il ritorno a capo per le descrizioni lunghe delle opzioni in base alla larghezza del terminale, mantenendo l’indentazione visualizzata, quindi verifica che l’output di esempio venga mandato a capo correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100