#source #span #metadata #string #value #types #track #up

nu-source

A source string characterizer for Nushell

15 breaking releases

new 0.21.0 Oct 13, 2020
0.19.0 Sep 2, 2020
0.17.0 Jul 21, 2020
0.12.0 Mar 31, 2020
0.1.0 Nov 27, 2019

#56 in Command-line interface

Download history 297/week @ 2020-06-28 198/week @ 2020-07-05 153/week @ 2020-07-12 490/week @ 2020-07-19 256/week @ 2020-07-26 279/week @ 2020-08-02 422/week @ 2020-08-09 262/week @ 2020-08-16 315/week @ 2020-08-23 422/week @ 2020-08-30 259/week @ 2020-09-06 175/week @ 2020-09-13 363/week @ 2020-09-20 224/week @ 2020-09-27 175/week @ 2020-10-04 364/week @ 2020-10-11

1,263 downloads per month
Used in 32 crates (31 directly)

MIT license

45KB
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.8–1.4MB
~32K SLoC