-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
Added support for adding custom arguments to tools. #588
Conversation
@patriksvensson there seems to be something screwy going on here: with the names of the files in this PR. Any ideas? |
@gep13 It's just a convention to name files containing generic classes using the CRef naming (i.e. Can change it to something else if you want to, but I think we should have some convention for it. |
@patriksvensson Gotcha! No, no need to change it. I just hadn't seen this before. My initial thought was that something had gone wrong with a merge/rebase etc, and the file name had got mangled 😄 Makes sense now that you explain it. Good to know, thanks! |
/// Gets or sets the arguments. | ||
/// </summary> | ||
/// <value>The arguments.</value> | ||
public Action<ProcessArgumentBuilder> ArgumentCustomization { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if it would make sense to have it be a Func instead if Action instead
public Func<ProcessArgumentBuilder, ProcessArgumentBuilder> ArgumentCustomization { get; set; }
so we could modify and return same instance, with the extension methods:
Settings.ArgumentCustomization = arg=>arg.Append("-true");
,but also just as easily return a new instance/exsisting instance.
Settings.ArgumentCustomization = arg=>"my new arguments";
...
Settings.ArgumentCustomization = arg=>reUseExistingArguments;
...
Settings.ArgumentCustomization = arg=>GetCustomNewArgs(param1, param2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add an extension method for this, but just providing an Action
is probably simpler and fits the most common use case where you want to add an argument that is missing.
If you completely want to rewrite the arguments, you could simply use the builder.Clear()
method before adding your arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda disagree, but might be personal preference.
Personally don't think this is unclean, unclear or less fluent.
Settings.ArgumentCustomization = builder=>"arg"
vs.
Settings.ArgumentCustomization = builder => {
builder.Clear();
builder.Append("Arg");
};
As the all the extension methods return a ProcessArgumentBuilder it would just work without any code change.
I would just find a Func
more flexible with little added complexity, would support any scenario the Action does plus a few more.
I think this one is ready to be merged 👍 |
Added support for adding custom arguments to tools.
Closes #500