-
Notifications
You must be signed in to change notification settings - Fork 2
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
API Design #12
Comments
cc @epage @killercup |
While I understand the assert_cli use cases, could you describe the other use cases so I better understand the requirements and what direction you're wanting to take this? Some questions that spawn from this
Misc thoughts
// Why any type of iterator
Environment::from_iter((0..5).into_iter()
.map(|x| (format!("KEY_{}", x), x)
); I feel the value comes from idiomatic interop with other types. |
The main use case is about tests environments. But I also use Environment for a CLI tools that spawn other command on differents machines.
To clone it in different Environment object. But in fact it's a corner case I think.
Like: env.var("foo").inherit();
or
let var = ("foo", "").into();
var.inherit(); I'm wondering, when accessing to a var on an environment.The inherit method must lookup only in the
When a condition fails on a particular key, the state stay the same. (Maybe I'm missing something on this question)
The macro style is, maybe, more visual. But in fact I don't know if it's really necessary. Maybe not. |
Cool, sounds like a fun project :)
Yes. I brought it up because you only had I expect I'll rarely, if ever, directly construct a
I feel I'm missing something here. Let me take a guess at answering. I like your definition of inherit in your PR
I was bringing it up because of this discussion
To be clear, I have no strong preference on this. I just figured it'd be nice if we standardized on pointing people to common, reusable patterns rather than every library reinventing these kinds of macros. |
I agree with the missing About ::std::env::set_var("foo", "testing");
let env = Environment::inherit()
.var("foo").assign("bar")
.var("foo").isnt("baz").inherit(); In this example, at the end of the chaining, do you want to have |
I'd probably classify that as a corner case and because of that my preference on behavior would be defined by what I think the primary case is. // Whitelisting environment variables to inherit
let env = Environment::empty().var("foo").inherit();
// Conditionally whitelisting environment variables to inherit
::std::env::set_var("foo", "testing");
let env = Environment::empty().var("foo").isnt("baz").inherit(); To make these cases successful, Therefore we should expect So ::std::env::set_var("foo", "testing");
let env = Environment::inherit()
.var("foo").assign("bar")
.var("foo").isnt("baz").inherit();
Another angle to look at this discussion is that |
Ok it's great and clear. So any call to |
Hello,
This issue will be the place to discuss about API Design.
The goal of Environment
Environment
is a crate to help users on creating/overriding/remove environments variables.It doesn't directly alter the current thread environment but offer a way to generate a representation of a potential environments.
Features
The user must be able to:
Feel free to add more feature here in comments
API Design
Instantiate Objects
You can instantiate an Environment different ways:
To instantiate a variable:
Variable manipulations
Here's some variable manipulations:
Integration with
Environment
object:To make a fluent API, the
Environment
object is passed to theVar
objectContribute
You can contribue to this PR just by commenting it.
The text was updated successfully, but these errors were encountered: