Skip to content

Fix ExtrasError. - #49

Merged
henryiii merged 3 commits into
CLIUtils:masterfrom
lambdafu:lambdafu/fixextraserror
Nov 21, 2017
Merged

henryiii merged 3 commits into
CLIUtils:masterfrom
lambdafu:lambdafu/fixextraserror

Conversation

@lambdafu

Copy link
Copy Markdown
Contributor

I noticed that ExtrasError wasn't showing the extra argument in a subcommand. So I dug deeper, and I could identify a bug in remaining(true), which was overwriting the miss_list instead of extending it. So, I added some tests and fixed it.
But then I noticed some bargled logic in triggering ExtrasError: Firstly, there is a mismatch between remaining(true) and remaining_size() (without true). Secondly, it didn't handle allow_extras_ and prefix_command_ on a per-subcommand basis. I tried a couple of things, but the easiest fix was to just let each subcommand fail on its own, by not using recurse=true at all.
As recurse=true is not used anymore (and because it does not handle allow_extras_ and prefix_command_), the recurse=true case could be removed from the code base. My patch doesn't do that, though, to keep the change minimal, in case there are some other plans or cases I missed. My recommendation would be to remove it if it doesn't serve any other purpose. I am not firm on the logic behind the fallthrough_ cases, so it may be that I am missing something.

@henryiii

Copy link
Copy Markdown
Collaborator

I'll look into this in more detail when I get a chance in the next day or two, but not surprised - that code was added very recently. I really need a series of more complex subcommsnd tests that mix features...

@codecov

codecov Bot commented Nov 21, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #49 into master will decrease coverage by 0.32%.
The diff coverage is 78.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
- Coverage     100%   99.67%   -0.33%     
==========================================
  Files           9        9              
  Lines        1230     1235       +5     
  Branches      248      248              
==========================================
+ Hits         1230     1231       +1     
- Misses          0        4       +4
Impacted Files Coverage Δ
include/CLI/App.hpp 99.41% <78.94%> (-0.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 675e753...bcb6528. Read the comment docs.

@henryiii
henryiii force-pushed the lambdafu/fixextraserror branch from 608ddfc to bcb6528 Compare November 21, 2017 18:17
@henryiii

Copy link
Copy Markdown
Collaborator

I've added a fix for the subcommand ordering, as well.

@henryiii

Copy link
Copy Markdown
Collaborator

I think recurse=true is still useful if someone just wants to collect all extras, possibly for debugging. I've added a test that makes sure it can rebuild the command line in order - which also fixes the callback order. I'm not sure if it has a practical use other than for diagnostics, since I would think users would always want to have the subcommands, as well. I agree with you that it should not be used if allow_extras is false - that should fail. Let me know if you have any thoughts!

By the way, the main purpose for fallthrough is to allow something like this:

./run_model model1 --common-opt --model1-opt

to work, where common options can be set on run_model but be given to subcommands. I'm not sure if the interaction with other models like prefix commands is perfect yet.

@henryiii
henryiii merged commit 9acaeeb into CLIUtils:master Nov 21, 2017
@henryiii

Copy link
Copy Markdown
Collaborator

Thanks!

@lambdafu
lambdafu deleted the lambdafu/fixextraserror branch November 21, 2017 22:43
@henryiii

Copy link
Copy Markdown
Collaborator

FYI, Windows requires #include <iterator> to use back_inserter. Fixed in master. :)

@henryiii henryiii added this to the v1.3 milestone Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants