tobimensch / cli2man

Converts the help message of a program into a manpage
25 stars 8 forks source link

--print-order and --set-order not working #10

Closed JOJ0 closed 1 year ago

JOJ0 commented 4 years ago

Hi again, --print-order and --set-order both fail like this:

$ cli2man --print-order
Section Order:
____________________
Traceback (most recent call last):
  File "/usr/local/bin/cli2man", line 1243, in <module>
    for section in manual.section_order:
NameError: global name 'manual' is not defined

I am using Python 2.7.16 installed via homebrew on macOS 10.13.6

JOJ0 commented 4 years ago

update: on another computer running Linux Mint and Python 2.7.5 I get better results even though not everything is working as expected.

tobimensch commented 4 years ago

I would have expected python to run the same way on Mac as on Linux, this is really disappointing to me, and I've no Mac machine to test this myself. You would have to provide me more detailed output, of the exact command line options given and everything that you've tried.

I think you might be right about your speculation as to why it doesn't work with "SEE ALSO". Most sections I came across when developing cli2man were just one word. This should be easy to fix, if someone gets the time to do it.

tobimensch commented 4 years ago

If you want me to help you, you have to provide detailed information about all the steps you took.

If you can, please provide me your input files. If not, provide some alternative use case I can try it on.

I can remember that this used to work, I've even included a specific command line option for the SEE ALSO section named --see-also, this must mean that I tested it at one point, and it worked then.

This bug report is vague and lacks detailed inputs that you made on the command line, and what exactly went wrong. For example in what way exactly ended the section order up being wrong?

JOJ0 commented 4 years ago

Sorry I can't find my exact outputs any more. This is one month ago already and my history doesn't have it anymore. I will try to reproduce all this again but I need to find the time. Please be patient and keep this issue open. Thanks!

This bug report is vague and lacks detailed inputs that you made on the command line, and what exactly went wrong. For example in what way exactly ended the section order up being wrong?

Well, if you think so..... I didn't want to invest too much time in the first place. I wanted to find out if you are responsive at all first.....and my efforts would be worth it. Also I wanted to move on with my project. Thanks for your tool. It helped my anyway.... :-)

BTW: The cli output / error message of --print-order is reported exactely as I experience it with the python version and os reported. I just reproduced it.

JOJ0 commented 4 years ago

I am using the version from git master branch and not the one you published on PyPI. I run it with Python 3.7.6.

cli2man is installed from git in a venv called "discodos":

(discodos) jojo@gin ~/git/discodos (master) $ which cli2man
/Users/jojo/.venvs/discodos/bin/cli2man

--print-order works flawlessly.

With --set-order I still have the issue that ordering doesn't always change correctly for SEE ALSO section.

I am using some sections from an include file: DESCRIPTION,SUBCOMMANDS,FILES,EXAMPLES,AUTHORS

(discodos) jojo@gin ~/git/discodos (master) $ cli2man disco --see-also disco-mix,disco-suggest,disco-import,disco-search --os DiscoDOS --include man/disco_add.mdoc --set-order "NAME,SYNOPSIS,DESCRIPTION,SUBCOMMANDS,OPTIONS,FILES,AUTHORS,EXAMPLES,SEE ALSO" -m

This is the very end of the output I am getting, for ease of reading I post it as man is viewing it (yes the order of the sections is the same in the generated mdoc source code):

AUTHORS
     bla bla

SEE ALSO
     disco-mix(1), disco-suggest(1), disco-import(1), disco-search(1)

EXAMPLES
     bla bla

DiscoDOS                        August 5, 2020                        DiscoDOS

Another example: If I flip AUTHORS and EXAMPLE and leave SEE ALSO at the end it works correctly! (I can also just leave out SEE ALSO completely in the --set-order list here and the result would be the same):

cli2man disco --see-also disco-mix,disco-suggest,disco-import,disco-search --os DiscoDOS --include man/disco_add.mdoc --set-order "NAME,SYNOPSIS,DESCRIPTION,SUBCOMMANDS,OPTIONS,FILES,EXAMPLES,AUTHORS,SEE ALSO" -m

This is the (correct) output:

EXAMPLES
     bla bla

AUTHORS
     bla bla

SEE ALSO
     disco-mix(1), disco-suggest(1), disco-import(1), disco-search(1)

DiscoDOS                        August 5, 2020                        DiscoDOS

And another one: But when I would like to put SEE ALSO in between EXAMPLES and AUTHORS now, the result is incorrect again:

cli2man disco --see-also disco-mix,disco-suggest,disco-import,disco-search --os DiscoDOS --include man/disco_add.mdoc --set-order "NAME,SYNOPSIS,DESCRIPTION,SUBCOMMANDS,OPTIONS,FILES,EXAMPLES,SEE ALSO,AUTHORS" -m

This would be the result of the last command:

EXAMPLES
     bla bla

AUTHORS
     bla bla

SEE ALSO
     disco-mix(1), disco-suggest(1), disco-import(1), disco-search(1)

DiscoDOS                        August 5, 2020                        DiscoDOS

I hope this clarifies what the problem is, please get back to me if you would like any specific test, I will find the time to report back :-)

tobimensch commented 4 years ago

Oh, yeah, that's what I consider to be really good bug reporting.

Thank you very much, that was a great job, and I'll look into it again.

Now I know what to look for!

tobimensch commented 4 years ago

@JOJ0 I can promise you, if you can give me your input files, then I can really make some progress. Without them it's really a lot of guess work, or I would have to make my own, but there's little time for it. So, with input files, I'll definitely give you a solution. Without them you may have to wait a while.

One thing you can do to help is to use this line: print(" --set-order \""+(','.join(manual.section_order[1:])+"\""))

In different places. For example in line 963 (before the for loop). Prepend another print call before it like print("Test in merge function"), and similar, to make it clear when viewing the output what really is happening.

I'm currently at a loss, because the code looks superficially right, but I have a hunch where the bug is.

Do the same in the lines 1338, 1348, 1356 and 1358.

JOJ0 commented 4 years ago

Hi Tobi, this is actually what I call disco_add.mdoc in above commands - had to rename it to txt so the fancy drag and drop uploader understands it ;-) disco_add.txt

This is the output of disco -h: disco_help.txt