Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse prints script debugging info #6703

Closed
NotTheDr01ds opened this issue Mar 3, 2020 · 1 comment
Closed

argparse prints script debugging info #6703

NotTheDr01ds opened this issue Mar 3, 2020 · 1 comment

Comments

@NotTheDr01ds
Copy link

NotTheDr01ds commented Mar 3, 2020

  • fish 3.1.0
  • Linux kings 4.4.0-18362-Microsoft Env vars not working. #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
  • screen-256color
  • Reproduced in "no customizations" shell
function foo
  argparse 'h/help' -- $argv
  or begin
    set -l s $status
    echo Usage:  foo -h
    return $s
  end

  echo Main function blah blah
end

The next two lines are optional:

funcsave foo
source ~/.config/fish/functions/foo.fish

Then: foo --bar

Expected:

foo: Unknown option '--bar'
Usage: foo -h

But instead we get script debugging info:

foo: Unknown option '--bar'
~/.config/fish/functions/foo.fish (line 2):
  argparse 'h/help' -- $argv
  ^
in function 'foo' with arguments '--bar'
Usage: foo -h

... which is ugly and really not useful to the end-user of the script. They just need to know that they entered an incorrect option and to try again. As it says in builtin_argparse.cpp, "... this particular error is not an error in argparse usage." So why is it still treated as such by printing script debug info?

This is also evident in any function shipped with fish that uses argparse. For instance:

funced --edior

@krobelus krobelus added this to the fish-future milestone Mar 7, 2020
@faho faho closed this as completed in a121833 Jun 17, 2020
@faho
Copy link
Member

faho commented Jun 17, 2020

Yeah, I made it so the stacktrace appears when we would also print the note about using help argparse - when it's an error in using argparse.

Passing an unknown option is an error in using the script that is using argparse, so we don't print those things.

@faho faho modified the milestones: fish-future, fish 3.2.0 Jun 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2020
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

3 participants