Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Unnecessary blank lines in "Unknown option" error #62

Closed
moll opened this issue Jul 11, 2016 · 6 comments
Closed

Unnecessary blank lines in "Unknown option" error #62

moll opened this issue Jul 11, 2016 · 6 comments

Comments

@moll
Copy link

moll commented Jul 11, 2016

Hey,

I modeled my usage text according to GNU conventions:

Usage: foo [options] [<file>]

Options:
    -h, --help     Display this help and exit.
    -V, --version  Display version and exit.

Calling Neodoc.run with it and passing an invalid option on the CLI, you'll get back an extraneous blank line (2 in total):

Usage: foo [options] [<file>]


Unknown option: -x

I take it's because of the blank line after Usage:.
I'd go with either zero, one or follow GNU utils or Git that print the error above the Usage line:

% ls --asdf
ls: unrecognized option '--asdf'
Try 'ls --help' for more information.
% git --asdf
Unknown option: --asdf
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

Cheers

@moll
Copy link
Author

moll commented Jul 11, 2016

Printing the app name before the error, like ls does, is useful for identifying which command failed in pipelines.

@felixSchl
Copy link
Owner

I think I cannot do Try 'ls --help' for more information. until #48 is taken care of, but I do like it. It would be great to have this configurable by user. I am going to consider the double lines a bug and fix that straight away and consider the improved help output an enhancement that needs a bit more planning - for example if we did make it configurable, how would this configuration look like? So far I tried to keep configuration simple, most things being just flags you can toggle because I was thinking I could do sth with template strings later and have a set of flags like regular expressions do.

@felixSchl
Copy link
Owner

@moll Do you think the program name should be an option or derived from the usage section? Or both, where configuration would take precedence? That leads into something else, I think this should be an "incoherent specification" error:

usage: foo
   or: bar

because the program name is said to be "foo" and "bar". What do you think?

felixSchl added a commit that referenced this issue Jul 12, 2016
felixSchl added a commit that referenced this issue Jul 12, 2016
Refer to issue #62 for discussion - Thanks @moll.
@felixSchl
Copy link
Owner

felixSchl commented Jul 12, 2016

with the lastest commit to feature/deriving-program-name, the output is as follows:

> node examples/git -sdf
git: unknown option: -sdf
usage: git [--version] [--help] [-C <path>] [-c <name=value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [<command> [<args>]...]

It's not configurable yet, however. I wonder if it even needs to be now.

felixSchl added a commit that referenced this issue Jul 12, 2016
Refer to issue #62 for discussion - Thanks @moll.
felixSchl added a commit that referenced this issue Jul 12, 2016
Refer to issue #62 for discussion - Thanks @moll.
@felixSchl
Copy link
Owner

This has been merged as of 005c826 and addresses all of the issues raised in the OP. If we want to make this configurable, we should track this in a new issue.

@felixSchl felixSchl added this to the Version 0.8.0 milestone Jul 13, 2016
@felixSchl
Copy link
Owner

felixSchl commented Jul 14, 2016

@moll you can try the new behaviour now at https://felixschl.github.io/neodoc (it's running a preview version of v0.8.0. feedback would be much appreciated)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants