-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Expose argv[0]
#11059
Labels
Milestone
Comments
This should also be used when reporting usage errors: > ./tools/build.nu
Error: nu::parser::missing_positional
× Missing required positional argument.
╭─[<commandline>:1:1]
1 │ main
· ▲
· ╰── missing src
╰────
help: Usage: main <src> <dest> . Use `--help` for more information. In the last line, |
fdncred
pushed a commit
that referenced
this issue
Dec 2, 2023
closes #11059 # Description I'm not sure what the consensus was after discussing this in discord, so I'm creating a PR as suggested # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> TBD # Tests + Formatting TBD <!-- 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 TBD <!-- 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. -->
hardfau1t
pushed a commit
to hardfau1t/nushell
that referenced
this issue
Dec 14, 2023
closes nushell#11059 # Description I'm not sure what the consensus was after discussing this in discord, so I'm creating a PR as suggested # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> TBD # Tests + Formatting TBD <!-- 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 TBD <!-- 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. -->
dmatos2012
pushed a commit
to dmatos2012/nushell
that referenced
this issue
Feb 20, 2024
closes nushell#11059 # Description I'm not sure what the consensus was after discussing this in discord, so I'm creating a PR as suggested # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> TBD # Tests + Formatting TBD <!-- 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 TBD <!-- 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. -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related problem
I would like
argv[0]
ie the name the script was invoked with, exposed in scriptsDescribe the solution you'd like
argv[0]
is available as thepath
argument here:nushell/crates/nu-cli/src/eval_file.rs
Line 19 in 77a1c3c
The information is lost here:
nushell/crates/nu-cli/src/eval_file.rs
Lines 34 to 44 in 77a1c3c
nushell/crates/nu-cli/src/eval_file.rs
Lines 97 to 100 in 77a1c3c
Describe alternatives you've considered
$"./($env.CURRENT_FILE | path relative-to (pwd))"
, but this is not necessarily the same thing asargv[0]
(an obvious exception is windows)Additional context and details
No response
The text was updated successfully, but these errors were encountered: