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

Remove required positional arg for some file system commands #11858

Merged
merged 2 commits into from Feb 15, 2024

Conversation

IanManske
Copy link
Member

Description

Fixes (most of) #11796. Some filesystem commands have a required positional argument which hinders spreading rest args. This PR removes the required positional arg from rm, open, and touch to be consistent with other filesystem commands that already only have a single rest arg (mkdir and cp).

User-Facing Changes

rm, open, and touch might no longer error when they used to, but otherwise there should be no noticeable changes.

@IanManske IanManske added the pr:commands This PR changes our commands in some way label Feb 14, 2024
SyntaxShape::GlobPattern,
"The file or files you want to remove.",
)
.rest("paths", SyntaxShape::GlobPattern, "The file paths(s) to remove.")
Copy link
Member

Choose a reason for hiding this comment

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

Do I read that right that this would now not complain about a missing path?

Maybe still worth raising an error at runtime. (Yes you could not completely freely run rm ...$my_unknown_list)
This would kind of give more peace of mind when running rm bare and you don't see any output.

Copy link
Member Author

@IanManske IanManske Feb 15, 2024

Choose a reason for hiding this comment

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

Maybe we could throw an error only if the syntax tree has no positional/rest arguments (call.rest_iter().next().is_none())? I.e., only a lone rm would fail:

> rm
Error ...

Copy link
Member

Choose a reason for hiding this comment

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

That would be a possibility, but somehow my taste develops in the direction that our internal commands should pull less tricks that you can not perform as a Nu library writer.
But maybe your suggestion gets us closer to fulfilling the expectations from #11796

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, in the future we should consider adding the required rest parameter that I think you mentioned. Otherwise, I think this is the best of both worlds that is currently possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it looks like the other filesystem commands error if the rest arg is empty. I'll just match their behavior for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@sholderbach sholderbach 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 quick turnaround!

@IanManske IanManske merged commit 903afda into nushell:main Feb 15, 2024
19 checks passed
@kubouch kubouch added this to the v0.91.0 milestone Feb 16, 2024
@rgwood
Copy link
Contributor

rgwood commented Feb 16, 2024

@IanManske Nice job on all the PRs this week!

dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
…#11858)

# Description
Fixes (most of) nushell#11796. Some filesystem commands have a required
positional argument which hinders spreading rest args. This PR removes
the required positional arg from `rm`, `open`, and `touch` to be
consistent with other filesystem commands that already only have a
single rest arg (`mkdir` and `cp`).

# User-Facing Changes
`rm`, `open`, and `touch` might no longer error when they used to, but
otherwise there should be no noticeable changes.
kik4444 pushed a commit to kik4444/nushell-fork that referenced this pull request Feb 28, 2024
…#11858)

Fixes (most of) nushell#11796. Some filesystem commands have a required
positional argument which hinders spreading rest args. This PR removes
the required positional arg from `rm`, `open`, and `touch` to be
consistent with other filesystem commands that already only have a
single rest arg (`mkdir` and `cp`).

`rm`, `open`, and `touch` might no longer error when they used to, but
otherwise there should be no noticeable changes.
@IanManske IanManske deleted the rest-file-names branch March 26, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:commands This PR changes our commands in some way
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants