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

Command line option handling issues #2890

Closed
codexnull opened this issue Jan 11, 2019 · 2 comments
Closed

Command line option handling issues #2890

codexnull opened this issue Jan 11, 2019 · 2 comments
Assignees
Labels
kind/maintenance Maintenance tasks, such as refactoring, with no impact in features.

Comments

@codexnull
Copy link
Contributor

codexnull commented Jan 11, 2019

The option handling has issues due to using both the standard flag package as well as Cobra/Viper. For example, running "dgraph --help" outputs

Usage of dgraph:
  -alsologtostderr
        log to standard error as well as files
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -logtostderr
        log to standard error instead of files
  -stderrthreshold value
        logs at or above this threshold go to stderr
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging

because which is

  1. Incorrect. -alsologtostderr is not a valid option, --alsologtostderr is.
  2. Not useful.

This behavior can be confusing to new users.

This example could be fixed by removing the call to flag.Parse() and just letting Cobra do all argument handling, but then the glog package complains that flag.Parse() has not been called, and that still leaves other issues (e.g. #2842, #2854), so something else needs to be done to make option handling more sane.

@codexnull codexnull self-assigned this Jan 11, 2019
@codexnull codexnull added kind/maintenance Maintenance tasks, such as refactoring, with no impact in features. backlog labels Jan 14, 2019
@manishrjain
Copy link
Contributor

We can fork glog and move that over to Cobra. But, the main issue here is that the way cobra handles flags is just annoying. Every flag needs to be defined and then retrieved back to see what the value is. Instead, we can just parse the config file ourselves (very easy to do) and set the flags values, before they are accessed by rest of the code. That way we don't need to call Gets on each and every flag.

@codexnull
Copy link
Contributor Author

This has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/maintenance Maintenance tasks, such as refactoring, with no impact in features.
Development

No branches or pull requests

2 participants