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

Allow input to take a specified number of characters #9242

Merged
merged 1 commit into from May 19, 2023

Conversation

merelymyself
Copy link
Contributor

Description

Title; fixes #9208.

User-Facing Changes

input now can specify a certain number of characters to read.

Tests + Formatting

No CI tests; can't find a way to implement.

~/CodingProjects/nushell> let user_input = (input --numchar 2)                                           
~/CodingProjects/nushell> echo $user_input                                                        
te

After Submitting

@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #9242 (987a872) into main (ca275f5) will decrease coverage by 0.03%.
The diff coverage is 41.86%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9242      +/-   ##
==========================================
- Coverage   68.54%   68.52%   -0.03%     
==========================================
  Files         636      636              
  Lines      102281   102319      +38     
==========================================
- Hits        70110    70109       -1     
- Misses      32171    32210      +39     
Impacted Files Coverage Δ
crates/nu-command/src/platform/input/input_.rs 29.37% <41.86%> (+1.32%) ⬆️

... and 4 files with indirect coverage changes

@fdncred
Copy link
Collaborator

fdncred commented May 19, 2023

Very nice. People have been asking for this.

Copy link
Collaborator

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

Thanks. I think it looks pretty good.

I was nitpicking your numchar parsing thinking this may be better

        let numchar = match numchar {
            Some(numchar) => numchar,
            None => Spanned {
                item: i64::MAX,
                span: call.head,
            },
        };

but it's doing the same thing anyway. So, it's no big deal.

@fdncred fdncred merged commit 01a0064 into nushell:main May 19, 2023
18 checks passed
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.

Introduce a way to read user's input, similar to "read" in Bash
2 participants