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

Port before_v0.60/cool_oneliners folder #831

Merged
merged 13 commits into from
May 13, 2024

Conversation

39555
Copy link
Contributor

@39555 39555 commented May 6, 2024

This PR is part of porting all old scripts #221 and ports cool_oneliners folder

Summary

dict.nu

This script has already been ported to sourced/cool_oneliners/dict.nu in
28c7e09

from: before_v0.60/cool_oneliners/dict.nu
to: sourced/cool-oneliners/dict.nu
functions:
  dict: sourced/cool-oneliners/dict.nu:2:dict

file_cat.nu

has already been ported to sourced/cool_oneliners/file_cat.nu in c47ccd4

  from: before_v0.60/cool_oneliners/file_cat.nu
  to: sourced/cool-oneliners/file_cat.nu

filesize.nu

from: before_v0.60/cool_oneliners/filesize.nu
to: sourced/cool-oneliners/filesize.nu

js_map_to_markdown.nu

from: before_v0.60/cool_oneliners/js_map_to_markdown.nu
to:  sourced/cool-oneliners/js_map_to_markdown.nu

I created sourced/cool-oneliners/assets/js_map.json with the data for this script as it was before

cdpath-implementation.nu

from: before_v0.60/cool_oneliners/cdpath-implementation.nu
to: sourced/cool-oneliners/cdpath-implementation.nu
functions:
  c: sourced/cool-oneliners/cdpath-implementation.nu:18:c

parse_aws_s3_ls.nu

I don't have aws so I just ported the syntax

from: before_v0.60/cool_oneliners/parse_aws_s3_ls.nu
to:  null

Edit: I considered not porting this script yet because I can't test it for now

npm_update_versions.nu

from: before_v0.60/cool_oneliners/npm_update_versions.nu
to: sourced/cool-oneliners/npm_update_versions.nu

xml_search_schema.nu

from: before_v0.60/cool_oneliners/xml_search_schema.nu
to: sourced/cool-oneliners/xml_search_schema.nu

39555 added 2 commits May 6, 2024 04:19
This script has already been updated `sourced/cool_oneliners/dict.nu` in
28c7e09
This script has already been ported to `sourced/cool_oneliners/file_cat.nu` in c47ccd4
@@ -0,0 +1,2 @@
## show file sizes in current directory starting from the largest
print (du --all | sort-by apparent | reverse | format filesize KB apparent)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change from ls -d to du --all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch. I got carried away a bit:) I have nu v0.44.0 and v0.32.0 and

  1. There is no apparent column in ls -d
  2. The command help format filesize has an example du | format filesize apparent B
  3. This script is about sizes

However I agree I should just porting and not rewriting so maybe I should simply change apparent to size and keep ls -d

39555 added 11 commits May 12, 2024 14:18
1. `Dir` -> `dir` changed in `nushell/nushell` commit 837f0463ebe650d2ebbf16722cde011f8559be30
2. update signature for `format filesize`
3. there is no `apparent` column in `ls -d` ever in version `< `0.44`, I've changed it to `size`
- create `cool_oneliners/assets/js_map.json` for `open assets/js_map.json`
- `$it` -> `$in` in the each closure
- add `flatten` for make it from `[[Español English]; [...], [Español English]; [...]]` to `[[Español English]; [...] [...]]`
- make actually code, not just string
- expand tabs to spaces
- `Dir` -> `dir`
- `each { if $it.type == Dir {echo $it.name} {} } ` -> `where type == dir`
- remove empty `else` in `if {...} {}`
- `echo` -> `print`
- fix: expand `$element` to match with (pwd)
- mention `nu_plugin_inc`
- full path in `ls`
- explicit `$it` in the `each` closure
- explicit <file> and `--force` in `save` for updating the destination
- `to json --pretty` -> `to json --indent`
`from xml` in modern `nu` has different shape.
Output is now a series of records with tag, attributes and content fields

nushell/nushell#7947
@39555 39555 force-pushed the port-before_v0.60/cool_oneliners branch from 7ef7611 to 8175f23 Compare May 12, 2024 12:51
@39555
Copy link
Contributor Author

39555 commented May 12, 2024

A cleaner attempt this time with

  • only porting
  • more verbose commit messages
  • first git mv, then changes

@fdncred fdncred merged commit b40ead9 into nushell:main May 13, 2024
1 check failed
@fdncred
Copy link
Collaborator

fdncred commented May 13, 2024

Thanks

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