Skip to content

Single-character wrapped lines with long options #231

Closed

Description

@OddBloke

When I run the script at the bottom I get the following output. I would, obviously, expect ALSOLONG to be all together on the second row.

Usage: example.py relatively_long example [OPTIONS] FIRST SECOND LONGISH
                                          A
                                          L
                                          S
                                          O
                                          L
                                          O
                                          N
                                          G

Error: Missing argument "first".

import click


@click.group()
def foo():
    pass


@foo.group()
def relatively_long():
    pass


@relatively_long.command()
@click.argument('first')
@click.argument('second')
@click.argument('longish')
@click.argument('alsolong')
def example():
    pass


foo()

Activity

  1. OddBloke commented on Sep 29, 2014

    @OddBloke
    Author

    This is on click 3.3 and Python 2.7.

  2. OddBloke commented on Sep 29, 2014

    @OddBloke
    Author

    I've just done a bit of digging, and the problem is that click passes a subsequent_indent in to textwrap.TextWrapper; this is subtracted from the total width available on all but the first line to determine how wide they can be. In this example, that means that all but the first line end up with a potential width of -5, hence the single character lines.

  3. sjagoe commented on Oct 21, 2014

    @sjagoe
    Contributor

    I have just run into this issue too. I'll try to have a stab at a PR for it tomorrow.

  4. JTFouquier commented on Mar 6, 2015

    @JTFouquier

    Hello. I was just wondering if there is any progress on this bug? My options are wrapping very far.

    T
    h
    a
    n
    k
    s
    !

    :)

  5. sjagoe commented on Mar 6, 2015

    @sjagoe
    Contributor

    I have an open PR for this. I might pull that out into some code that can be applied in projects using click if the PR doesn't get reviewed.

  6. sjagoe commented on Mar 6, 2015

    @sjagoe
    Contributor

    @untitaker Are you able to look at #240?

  7. untitaker commented on Mar 6, 2015

    @untitaker
    Contributor

    I don't think it's the correct solution. I'm at a loss why Click wants to indent all options to match up with the command name... generally this is not going to fly on smaller terminals.

  8. sjagoe commented on Mar 7, 2015

    @sjagoe
    Contributor

    so you would suggest just wrapping to the next line, maybe with a small indent (4-8 spaces)?

  9. JTFouquier commented on Mar 16, 2015

    @JTFouquier

    Does anyone have a suggestion for how to get around this issue in the most efficient way possible? I used Python 2.7, but if I switch to 3.0 will that fix it? Or anything less time intensive? Thank you for any pointers!

  10. untitaker commented on Mar 16, 2015

    @untitaker
    Contributor

    I haven't looked into the issue properly. #240 is a workaround, but a proper fix is needed.

  11. JTFouquier commented on Mar 16, 2015

    @JTFouquier

    Okay, I see #240 changes formatting.py but i figured this was something that needed to be done in Click and then I'd reinstall Click. Is this something I can change locally? Thanks for your time. I'm new to software development (I generally do scripting/bioinformatics). If you are too busy, no worries! Thanks! @sjagoe

  12. untitaker commented on Mar 16, 2015

    @untitaker
    Contributor

    If you want to try #240:

    git clone https://github.com/mitsuhiko/click
    cd click
    git fetch origin pull/240/head:tmp
    git checkout tmp
    python setup.py install
    
  13. sjagoe commented on Mar 16, 2015

    @sjagoe
    Contributor

    sorry, I haven't had time to come back to this yet. I'll try to revisit it this week for another fix.

  14. locked as resolved and limited conversation to collaborators on Nov 13, 2020
  15. added this to the 4.0 milestone on Aug 8, 2026
  16. added
    parsing
    on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    parsing

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions