Skip to content

support plus sign for "into filesize"#12974

Merged
WindSoilder merged 6 commits intonushell:mainfrom
hqsz:fix_into_filesize_positive_string
Jun 4, 2024
Merged

support plus sign for "into filesize"#12974
WindSoilder merged 6 commits intonushell:mainfrom
hqsz:fix_into_filesize_positive_string

Conversation

@hqsz
Copy link
Copy Markdown
Contributor

@hqsz hqsz commented May 26, 2024

Description

Fixes #12968. After apply this patch, we can use explict plus sign character included string with into filesize cmd.

User-Facing Changes

AS-IS (before fixing)

$ "+8 KiB" | into filesize                                                                                                         
Error: nu::shell::cant_convert

  × Can't convert to int.
   ╭─[entry #31:1:1]
 1 │ "+8 KiB" | into filesize
   · ────┬───
   ·     ╰── can't convert string to int
   ╰────

TO-BE (after fixing)

$ "+8KiB" | into filesize                                                                                       
8.0 KiB

Tests + Formatting

Added a test

After Submitting

Copy link
Copy Markdown
Member

@IanManske IanManske left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It looks like strings that start with a plus sign already worked if they did not have a filesize unit (e.g., '+1' | into filesize). So, with this PR, '++1' | into filesize now works 👀.

Copy link
Copy Markdown
Member

@IanManske IanManske left a comment

Choose a reason for hiding this comment

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

Looks good! Just two minor things:

@hqsz
Copy link
Copy Markdown
Contributor Author

hqsz commented May 29, 2024

Thanks for reviewing! I also left some minor questions which is occurred while i writing new codes.

Copy link
Copy Markdown
Member

@IanManske IanManske left a comment

Choose a reason for hiding this comment

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

We are currently in the process of doing a patch release. This PR will be merged after that. Thanks for all of your work here!

@IanManske IanManske added status:wait-until-after-nushell-release notes:fixes Include the release notes summary in the "Bug fixes" section deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead labels May 30, 2024
@WindSoilder WindSoilder merged commit 3f0db11 into nushell:main Jun 4, 2024
@hustcer hustcer added this to the v0.95.0 milestone Jun 5, 2024
@hqsz hqsz deleted the fix_into_filesize_positive_string branch June 9, 2024 12:57
WindSoilder pushed a commit that referenced this pull request Jun 10, 2024
# Description
Fix wrong casting which is related to
#12974 (comment)

# User-Facing Changes
AS-IS (before fixing)
```
$ "-10000PiB" | into filesize
6.2 EiB                                                         <--- Wrong casted value
$ "10000PiB" | into filesize 
-6.2 EiB                                                        <--- Wrong casted value
```

TO-BE (after fixing)
```
$ "-10000PiB" | into filesize
Error: nu::shell::cant_convert

  × Can't convert to filesize.
   ╭─[entry #6:1:1]
 1 │ "-10000PiB" | into filesize
   · ─────┬─────
   ·      ╰── can't convert string to filesize
   ╰────

$ "10000PiB" | into filesize
Error: nu:🐚:cant_convert

  × Can't convert to filesize.
   ╭─[entry #7:1:1]
 1 │ "10000PiB" | into filesize
   · ─────┬────
   ·      ╰── can't convert string to filesize
   ╰────
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated:pr-commands (deprecated: too vague) This PR changes our commands in some way deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead notes:fixes Include the release notes summary in the "Bug fixes" section status:wait-until-after-nushell-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

into filesize can't handle the + sign

4 participants