nushell/crates
Justin Ma 95f89a093a
Add ansi codes to move cursor position (#15221)
<!--
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.
-->

Add ansi codes to move cursor position: `ansi cursor_left`, `ansi
cursor_right`, `ansi cursor_up`, `ansi cursor_down`
Why I add these? I'm trying to add a spinner to the message end for a
long running task, just to find that I need to move the cursor left to
make it work as expected: `with-progress 'Waiting for the task to
finish' { sleep 10sec }`
```nu
def with-progress [
  message: string,         # Message to display
  action: closure,         # Action to perform
  --success: string,       # Success message
  --error: string          # Error message
] {
  print -n $'($message)   '
  # ASCII spinner frames
  let frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']

  # Start the spinner in the background
  let spinner_pid = job spawn {
    mut i = 0
    print -n (ansi cursor_off)
    loop {
      print -n (ansi cursor_left)
      print -n ($frames | get $i)
      sleep 100ms
      $i = ($i + 1) mod ($frames | length)
    }
  }

  # Run the action and capture result
  let result = try {
    do $action
    { success: true }
  } catch {
    { success: false }
  }

  # Stop the spinner
  job kill $spinner_pid
  print "\r                                                  \r"

  # Show appropriate message
  if $result.success {
    print ($success | default '✓ Done!')
  } else {
    print ($error | default '✗ Failed!')
    exit 1
  }
}
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# 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 toolkit.nu; toolkit test stdlib"` 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.
-->
2025-03-01 11:30:00 -06:00
..
nu_plugin_custom_values Rework operator type errors (#14429) 2025-02-12 20:03:40 -08:00
nu_plugin_example Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_formats Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_gstat Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_inc Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_nu_example Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_polars polars strip-chars: Allow any polars expression for pattern argument (#15178) 2025-02-25 17:59:02 -06:00
nu_plugin_python Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_query update query json help and examples (#15190) 2025-02-26 09:15:14 -06:00
nu_plugin_stress_internals Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-cli fix(lsp): completion of commands defined after the cursor (#15188) 2025-03-01 06:21:53 -06:00
nu-cmd-base Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-cmd-extra Refactor/fix tests affecting the whole command set (#15073) 2025-02-11 11:36:36 +01:00
nu-cmd-lang add attr category @category to custom command attributes (#15137) 2025-02-18 15:35:52 -06:00
nu-cmd-plugin Refactor/fix tests affecting the whole command set (#15073) 2025-02-11 11:36:36 +01:00
nu-color-config Rework operator type errors (#14429) 2025-02-12 20:03:40 -08:00
nu-command Add ansi codes to move cursor position (#15221) 2025-03-01 11:30:00 -06:00
nu-derive-value Use proc-macro-error2 instead of proc-macro-error (#15093) 2025-02-11 15:13:34 -05:00
nu-engine check signals in nu-glob and ls (#15140) 2025-02-28 19:36:39 +01:00
nu-explore fix: new clippy warnings from rust 1.85.0 (#15203) 2025-02-27 14:11:47 +01:00
nu-glob check signals in nu-glob and ls (#15140) 2025-02-28 19:36:39 +01:00
nu-json fix: new clippy warnings from rust 1.85.0 (#15203) 2025-02-27 14:11:47 +01:00
nu-lsp fix(lsp): completion of commands defined after the cursor (#15188) 2025-03-01 06:21:53 -06:00
nu-parser fix: new clippy warnings from rust 1.85.0 (#15203) 2025-02-27 14:11:47 +01:00
nu-path Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-plugin Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-plugin-core Replaced IoError::new_with_additional_context calls that still had Span::unknown() (#15056) 2025-02-08 09:23:28 -06:00
nu-plugin-engine Rework operator type errors (#14429) 2025-02-12 20:03:40 -08:00
nu-plugin-protocol make plugin compatible with nightly nushell version (#15084) 2025-02-11 06:40:15 -06:00
nu-plugin-test-support Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-pretty-hex Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-protocol fix(completion): edge cases of operator completions (#15169) 2025-02-28 19:39:59 +01:00
nu-std allow bench to handle larger numbers (#15162) 2025-02-25 15:02:42 +01:00
nu-system Jobs (#14883) 2025-02-25 12:09:52 -05:00
nu-table Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-term-grid Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-test-support fix(test-support): use CARGO_BUILD_TARGET_DIR env var (#15212) 2025-02-28 20:08:44 +01:00
nu-utils Remove inheritance for PROMPT variables created in default_env.nu (#15130) 2025-02-21 10:08:10 -05:00
nuon Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.