#nu-shell

nu-source

A source string characterizer for Nushell

38 breaking releases

0.44.0 Feb 8, 2022
0.42.0 Dec 28, 2021
0.40.0 Nov 16, 2021
0.34.0 Jul 13, 2021
0.1.0 Nov 27, 2019

#1376 in Command-line interface

Download history 380/week @ 2024-12-09 242/week @ 2024-12-16 102/week @ 2024-12-23 76/week @ 2024-12-30 148/week @ 2025-01-06 159/week @ 2025-01-13 214/week @ 2025-01-20 164/week @ 2025-01-27 227/week @ 2025-02-03 201/week @ 2025-02-10 311/week @ 2025-02-17 206/week @ 2025-02-24 84/week @ 2025-03-03 118/week @ 2025-03-10 184/week @ 2025-03-17 107/week @ 2025-03-24

518 downloads per month
Used in 32 crates (29 directly)

MIT license

46KB
1.5K SLoC

nu-source

Overview

The nu-source crate contains types and traits used for keeping track of metadata about values being processed. Nu uses Tags to keep track of where a value came from, an AnchorLocation, as well as positional information about the value, a Span. An AnchorLocation can be a Url, File, or Source text that a value was parsed from. The source Text is special in that it is a type similar to a String that comes with the ability to be cheaply cloned. A Span keeps track of a value's start and end positions. These types make up the metadata for a value and are wrapped up together in a Tagged struct, which holds everything needed to track and locate a value.

Nu's metadata system can be seen when reporting errors. In the following example Nu is able to report to the user where the typo of a column originated from.

1 | ls | get typ
  |          ^^^ did you mean 'type'?

In addition to metadata tracking, nu-source also contains types and traits related to debugging, tracing, and formatting the metadata and values it processes.

Other Resources

Dependencies

~0.5–8MB
~56K SLoC