Skip to content
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

Add commands for parsing many files. #23

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

doriath
Copy link
Contributor

@doriath doriath commented Dec 8, 2024

Two new commands are added to the toolkit - parse-all and summary.

This allows one to easily run the parser on many nu scripts and analyze how many of the scripts fail to parse.

Example report from running on https://github.com/nushell/nu_scripts:

$ summary (parse-all ../nu_scripts/)
Total files: 1493
Errors: 1375
Crashes: 115
Successes: 3
Sample error file: /home/doriath/code/nu_scripts/modules/formats/to-number-format.nu
Sample crash file: /home/doriath/code/nu_scripts/modules/jc/mod.nu
Slowest file: 297ms 768µs 822ns /home/doriath/code/nu_scripts/custom-completions/auto-generate/completions/mvn.nu

@kubouch
Copy link
Collaborator

kubouch commented Dec 8, 2024

Thanks, this looks useful. Can you add small snippets how to use these commands to their comments?

Two new commands are added to the toolkit - parse-all and summary.

This allows one to easily run the parser on many nu scripts and analyze
how many of the scripts fail to parse.

Example report from running on https://github.com/nushell/nu_scripts:

```
$ summary (parse-all ../nu_scripts/)
Total files: 1493
Errors: 1375
Crashes: 115
Successes: 3
Sample error file: /home/doriath/code/nu_scripts/modules/formats/to-number-format.nu
Sample crash file: /home/doriath/code/nu_scripts/modules/jc/mod.nu
Slowest file: 297ms 768µs 822ns /home/doriath/code/nu_scripts/custom-completions/auto-generate/completions/mvn.nu
```
@doriath
Copy link
Contributor Author

doriath commented Dec 9, 2024

As recommended, added some comments. I did few more changes:

  • fix the script to accept the paths to direct nu shell files, instead of just directories
  • fix the formatting (use 4 space indent, to match the formatting in span command
  • add export to the commands (I think it is needed so that commands are available after use toolkit.nu ?)

Also, I was wondering if it would be better for the summary to accept a pipe instead of argument? e.g. parse-all ../nu_scripts | sumary instead of current summary (parse-all ../nu_scripts)

@kubouch
Copy link
Collaborator

kubouch commented Dec 9, 2024

Nice, thanks! Yeah, the pipe might be nicer, but not a big deal. I'll merge as-is, but feel free to continue tweaking.

@kubouch kubouch merged commit 1865c9d into nushell:main Dec 9, 2024
4 checks passed
@doriath doriath deleted the parse-all-summary branch January 2, 2025 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants