Would be nice if long descriptions were handled better
Personne n'a encore pris cette issue.
- Langage dominant
- Ruby
- Étoiles
- 71
- Forks
- 27
- Merge moyen
- 3 h 3 min
- PR mergées (30 j)
- 2
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par la sortie d’aide de OptionParser affichée pour opts.rb et suivez le chemin de formatage utilisé par -h. Implémentez le retour à la ligne des descriptions d’options longues en fonction de la largeur du terminal, tout en préservant l’indentation affichée, puis vérifiez que la sortie d’exemple est correctement répartie sur plusieurs lignes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- ruby
- Domaine
- cli
- Type d'issue
- Fonctionnalité
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100