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

tool: do more command line parsing in sub functions #15680

Closed
wants to merge 1 commit into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Dec 4, 2024

This moves argument parsing logic for a number of options into sub functions to reduce the overall complexity of the single getparameter() function. pmccabe says it takes complexity down from 234 to 147.

The command line options that now has dedicated parser funtions are:

--continue-at, --ech, --header, --localport, --output, --quote, --range
--remote-name, --time-cond, --upload-file, --url, --verbose, --writeout

These parsers were selected for thise because they had more than 15 lines of logic in the main switch(). Detected like this:

git grep -hn 'case C_' tool_getparam.c |
cut -d: -f1 |
awk '{if(($1 - prev) > 15) { printf "%d\n", prev;} prev = $1;}'

This moves argument parsing logic for a number of options into sub
functions to reduce the overall complexity of the single getparameter()
function. pmccabe says it takes complexity down from 234 to 147.

The command line options that now has dedicated parser funtions are:

 --continue-at, --ech, --header, --localport, --output, --quote, --range
 --remote-name, --time-cond, --upload-file, --url, --verbose, --writeout

These parsers were selected for thise because they had more than 15
lines of logic in the main switch(). Detected like this:

 git grep -hn 'case C_' tool_getparam.c |
  cut -d: -f1 |
  awk '{if(($1 - prev) > 15) { printf "%d\n", prev;} prev = $1;}'
src/tool_getparam.c Dismissed Show dismissed Hide dismissed
src/tool_getparam.c Dismissed Show dismissed Hide dismissed
@bagder bagder closed this in 509f50e Dec 4, 2024
@bagder bagder deleted the bagder/splitup-getparam branch December 4, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant