Repository navigation
implement whoami using uutils - #10488
Conversation
|
Thanks @tertsdiepraam. Looks like you were right when you said that |
|
Indeed! It's a very simple command without any flags. And it's a good excuse to implement conversion for errors as well. If you approve the CI now, the tests should work, because the PR has been merged on our side! |
|
i restarted the ci but there are more ci errors. something else must be going on. |
|
@fdncred Ah yeah, some dependency conflicts. Should be fixed now (at least works for me now with |
|
@tertsdiepraam looks like you need |
|
I figured my example covered that, but I suppose that's |
ya, nothing -> nothing may be a bug on our side? |
|
Ah, the latest CI failure is because we don't allow substrings of the command name to be in the search terms, so |
|
Haha alright, I'll fix that up, too. |
|
If I'm not mistaken, this is unblocked by the latest uutils release. I'm on holiday, so I can't fix the |
|
I have just one comment about the error conversion. In Nushell, errors with spans should be used unless absolutely necessary. The ShellError::IOError conversion is more of a technical debt on our side that we should remove or add a span to it. Otherwise cool, I have no complaints. |
|
Alright, so the span here would just be |
|
I made some quick changes to this to add a span to the error message. I removed the way the previous error message was created. At some point, we need to add a good way to map between I also added |
|
Excellent! Exactly what I had in mind! I'll think about easier conversion of the error types for the other utils. I can't approve this PR, because it's my own, but consider it approved 😄 |
|
Thanks @tertsdiepraam. Any help you can provide with better error handling between coreutils and nushell would be appreciated. We'll probably wait on landing this until after the release. We're very cautious about landing PR without a couple days of a release. We've been burned on that in the past. |
|
I understand completely! We'll test this properly after the release 👍 |
|
Instead of implementing the |
|
Yeah it could be something along those lines! Definitely sounds like a good idea for the simple cases like this one. Sometimes we might also want some more control. It might be nice for instance if there was some way for uutils to indicate which argument caused the error. Even better, we might be able to rework the uutils errors some more to make those pretty too! I'm a bit jealous of those pretty miette errors 😄 That would be using the same information then. |
|
not sure i remember if there was some other blocker for this PR? 🤔 if not, @tertsdiepraam, could you fix the |
|
Thanks @tertsdiepraam! I forgot about this one, LOL. |
|
I think we definitely still need to work on the |
|
I was working on fixing these conflicts at the same time and so confused when everything was suddenly fixed 😄 Thanks for the fixes! |
|
lolz, sorry for fixing them from underneath you. |
<!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> Implements `whoami` using the `whoami` command from uutils as backend. This is a draft because it depends on uutils/coreutils#5310 and a new release of uutils needs to be made (and the paths in `Cargo.toml` should be updated). At this point, this is more of a proof of concept 😄 Additionally, this implements a (simple and naive) conversion from the uutils `UResult` to the nushell `ShellError`, which should help with the integration of other utils, too. I can split that off into a separate PR if desired. I put this command in the "platform" category. If it should go somewhere else, let me know! The tests will currently fail, because I've used a local path to uutils. Once the PR on the uutils side is merged, I'll update it to a git path so that it can be tested and runs on more machines than just mine. # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> New `whoami` command. This might break some users who expect the system `whoami` command. However, the result of this new command should be very close, just with a nicer help message, at least for Linux users. The default `whoami` on Windows is quite different from this implementation: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoami # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> --------- Co-authored-by: Darren Schroeder <[email protected]>
Description
Implements
whoamiusing thewhoamicommand from uutils as backend. This is a draft because it depends on uutils/coreutils#5310 and a new release of uutils needs to be made (and the paths inCargo.tomlshould be updated). At this point, this is more of a proof of concept 😄Additionally, this implements a (simple and naive) conversion from the uutils
UResultto the nushellShellError, which should help with the integration of other utils, too. I can split that off into a separate PR if desired.I put this command in the "platform" category. If it should go somewhere else, let me know!
The tests will currently fail, because I've used a local path to uutils. Once the PR on the uutils side is merged, I'll update it to a git path so that it can be tested and runs on more machines than just mine.
User-Facing Changes
New
whoamicommand. This might break some users who expect the systemwhoamicommand. However, the result of this new command should be very close, just with a nicer help message, at least for Linux users. The defaultwhoamion Windows is quite different from this implementation: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoamiTests + Formatting
After Submitting