-
Notifications
You must be signed in to change notification settings - Fork 480
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
Add ability to skip options with default values for UnParserSettings #541
Comments
I agree with you to skip the parameters that have default values. |
I just want to confirm this test case: class Options
{
[Option(Default = 99)] //should be skipped when P1=99
public int P1 { get;set;}
[Option()]
public string P2 { get;set;}
[Option(Default = 88)] //should be skipped when P3=88
public int P3 { get;set;}
}
var options = new Options{P2="xyz" ,P1=99, P3=88} ;
args should be: --p2 xyz Is it right? |
Yes, this is exactly what I mean |
@MichaelMankiewicz |
Example: var options = new Options_With_Defaults {P2 = "xyz", P1 = 99, P3 = 88,P4= Shapes.Square } ;
var args= new Parser()
//Configure Unparser: SkipDefault=true
.FormatCommandLine(options,x=>x.SkipDefault=true) ;
class Options_With_Defaults
{
[Option(Default = 99)]
public int P1 { get; set; }
[Option()]
public string P2 { get; set; }
[Option(Default = 88)]
public int P3 { get; set; }
[Option(Default = Shapes.Square)]
public Shapes P4 { get; set; } //enum option
} result:
|
Fixed in v2.7+, See wiki with online demo |
I have many command line parameters with default values in most of them. My app generates
.bat
file to run itself with parameters which passed to it's main instance. NowParser.Default.FormatCommandLine
makes long string with all parameters, most of which has default values and can be omitted.I want to be able to set
UnParserSettings
to skip parameters that has default values when I use it asFormatCommandLine
action's parameter. Is it possible?The text was updated successfully, but these errors were encountered: