Skip to content

Add --env and --wrapped flags to def#10566

Merged
kubouch merged 7 commits intonushell:mainfrom
kubouch:def-env-wrapped
Oct 2, 2023
Merged

Add --env and --wrapped flags to def#10566
kubouch merged 7 commits intonushell:mainfrom
kubouch:def-env-wrapped

Conversation

@kubouch
Copy link
Copy Markdown
Contributor

@kubouch kubouch commented Oct 1, 2023

Description

This PR adds --env and --wrapped flags to def to be used instead of def-env and extern-wrapped. This allows def --env --wrapped to be used together, which was not possible before. In addition, it reduces the number of keywords we have and avoids the confusion of extern-wrapped being, in fact, a normal command, not a known external.

Deprecation strategy

Because def-env is used everywhere, including virtualenv, I propose the following steps:

  • 0.86: Add this PR, keep def-env and extern-wrapped unchanged.
  • 0.87: Add deprecation warning to def-env and extern-wrapped but keep them working.
  • 0.88 (or later): Remove def-env and extern-wrapped.

Possible caveat

There is a silent failure if you put the flag between the signature and the block, e.g., def spam [] --env {}. I suspect it's because of some signature parsing weirdness. Because signatures are not first-class values, I noticed some weird behavior when I tried to parse them in value situations, such as let x: signature = .... Not 100% but it might be related. Given the new parser is underway, I didn't investigate further, as this code will be replaced anyway.

Doing def spam [] {} --env fails with a missing positional error which is also quite unhelpful, but at least it fails

User-Facing Changes

Apart from the added flags, no changes. There should be no breakages (yet...).

Tests + Formatting

After Submitting

@sophiajt
Copy link
Copy Markdown
Contributor

sophiajt commented Oct 1, 2023

Looks good. Just had one question about you were handling errors for incomplete defs

@kubouch kubouch merged commit eb6870c into nushell:main Oct 2, 2023
@kubouch kubouch deleted the def-env-wrapped branch October 2, 2023 18:13
WindSoilder pushed a commit that referenced this pull request Oct 19, 2023
follow-up to
- #10566

# Description
this PR deprecates the use of `extern-wrapped` and `export
extern-wrapped`

these two core commands will be removed in 0.88

# User-Facing Changes
using `extern-wrapped` will give a warning
```nushell
> extern-wrapped foo [...args] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry #2:1:1]
 1 │ extern-wrapped foo [...args] { print "foo" }; foo
   · ───────┬──────
   ·        ╰── `extern-wrapped` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --wrapped` instead


foo
```

# Tests + Formatting

# After Submitting
WindSoilder pushed a commit that referenced this pull request Oct 19, 2023
follow-up to
- #10566

# Description
this PR deprecates the use of `def-env` and `export def-env`

these two core commands will be removed in 0.88

# User-Facing Changes
using `def-env` will give a warning
```nushell
> def-env foo [] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry #1:1:1]
 1 │ def-env foo [] { print "foo" }; foo
   · ───┬───
   ·    ╰── `def-env` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --env` instead


foo
```

# Tests + Formatting

# After Submitting
gaetschwartz pushed a commit to gaetschwartz/nushell that referenced this pull request Oct 20, 2023
follow-up to
- nushell#10566

# Description
this PR deprecates the use of `extern-wrapped` and `export
extern-wrapped`

these two core commands will be removed in 0.88

# User-Facing Changes
using `extern-wrapped` will give a warning
```nushell
> extern-wrapped foo [...args] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry nushell#2:1:1]
 1 │ extern-wrapped foo [...args] { print "foo" }; foo
   · ───────┬──────
   ·        ╰── `extern-wrapped` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --wrapped` instead


foo
```

# Tests + Formatting

# After Submitting
gaetschwartz pushed a commit to gaetschwartz/nushell that referenced this pull request Oct 20, 2023
follow-up to
- nushell#10566

# Description
this PR deprecates the use of `def-env` and `export def-env`

these two core commands will be removed in 0.88

# User-Facing Changes
using `def-env` will give a warning
```nushell
> def-env foo [] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry nushell#1:1:1]
 1 │ def-env foo [] { print "foo" }; foo
   · ───┬───
   ·    ╰── `def-env` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --env` instead


foo
```

# Tests + Formatting

# After Submitting
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
follow-up to
- nushell#10566

# Description
this PR deprecates the use of `extern-wrapped` and `export
extern-wrapped`

these two core commands will be removed in 0.88

# User-Facing Changes
using `extern-wrapped` will give a warning
```nushell
> extern-wrapped foo [...args] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry nushell#2:1:1]
 1 │ extern-wrapped foo [...args] { print "foo" }; foo
   · ───────┬──────
   ·        ╰── `extern-wrapped` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --wrapped` instead


foo
```

# Tests + Formatting

# After Submitting
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
follow-up to
- nushell#10566

# Description
this PR deprecates the use of `def-env` and `export def-env`

these two core commands will be removed in 0.88

# User-Facing Changes
using `def-env` will give a warning
```nushell
> def-env foo [] { print "foo" }; foo
Error:   × Deprecated command
   ╭─[entry #1:1:1]
 1 │ def-env foo [] { print "foo" }; foo
   · ───┬───
   ·    ╰── `def-env` is deprecated and will be removed in 0.88.
   ╰────
  help: Use `def --env` instead


foo
```

# Tests + Formatting

# After Submitting
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