j-maly / CommandLineParser

Command line parser. Declarative arguments support. Rich set of argument types (switches, enums, files, etc...). Mutually exclusive arguments validations.
MIT License
137 stars 30 forks source link

Prevent argument value from being printed to console #40

Closed mhsimkin closed 7 years ago

mhsimkin commented 7 years ago

The ShowUsage() and ShowParsedArguments() methods will print all the arguments supplied to the console.

One of the arguments that I have for my application is a password.

How can I prevent the password from being show in the clear when ShowUsage() and ShowParsedArguments() called?

Thanks

marc

j-maly commented 7 years ago

1) if I recall correctly, ShowUsage doesn't print any values supplied 2) ShowParsedArguments() will indeed print all parsed values. There is no builtin flag or function to not print values in ShowParsedArguments. Since this is quite a special case, I'd suggest you just clear the value of the password argument (or replace it with something like "*****") before calling ShowParsedArguments()

mhsimkin commented 7 years ago

Hi. Thank you.

If I decided to create a custom Argument parser class, do I just need to override the PrintValueInfo() method to suppress the print of the value there?

Thanks

marc

j-maly commented 7 years ago

Yes, exactly. If you decide to create a PR, I'll be happy to merge it into the main code.