mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
minor changes to nu_conda.nu and nu_msvs.nu (#576)
1. feat(nu_conda): add `nu_conda list` to list available envs 2. fix: use `print` instead of `echo` to print warnings 3. doc: change minimum support version to 0.83.0
This commit is contained in:
parent
90a8b0d96b
commit
e60d20733e
4 changed files with 30 additions and 16 deletions
|
@ -3,7 +3,7 @@ A simple module for activating and deactivating Conda environments.
|
|||
|
||||
|
||||
## Prerequisites
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.73.0
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.83.0
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -15,6 +15,7 @@ Put `nu_conda.nu` into the module folder of your nushell configuration workspace
|
|||
use nu_conda.nu # activate module
|
||||
nu_conda activate py36 # activate a Conda environment, e.g. py36
|
||||
nu_conda deactivate # deactivate the activated Conda environment
|
||||
nu_conda list # list available environments, same as `$env.CONDA_ENVS`
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
|
|
@ -24,13 +24,13 @@ export-env {
|
|||
|
||||
export def-env activate [name: string] {
|
||||
if ($env.CONDA_ROOT | is-empty) {
|
||||
echo "Neither Conda nor Mamba is valid."
|
||||
print "Neither Conda nor Mamba is valid."
|
||||
return
|
||||
}
|
||||
|
||||
if not $name in $env.CONDA_ENVS {
|
||||
echo $"Environment ($name) is invalid. Available:"
|
||||
echo $env.CONDA_ENVS
|
||||
if not ($name in $env.CONDA_ENVS) {
|
||||
print $"Environment ($name) is invalid. Available:"
|
||||
print $env.CONDA_ENVS
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export def-env activate [name: string] {
|
|||
|
||||
export def-env deactivate [] {
|
||||
if ($env.CONDA_ROOT | is-empty) {
|
||||
echo "Neither Conda nor Mamba is valid."
|
||||
print "Neither Conda nor Mamba is valid."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,10 @@ export def-env deactivate [] {
|
|||
load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH}
|
||||
}
|
||||
|
||||
export def-env list [] {
|
||||
print $env.CONDA_ENVS
|
||||
}
|
||||
|
||||
def update-path-linux [env_path: path] {
|
||||
let env_path = [
|
||||
$env_path,
|
||||
|
|
|
@ -3,7 +3,7 @@ A module for Using Microsoft Visual Studio (MSVS) command line tools from Nushel
|
|||
|
||||
|
||||
## Prerequisites
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.73.0
|
||||
- [nushell](https://github.com/nushell/nushell) >= 0.83.0
|
||||
- [vswhere](https://github.com/microsoft/vswhere) standalone or comes with VS
|
||||
|
||||
|
||||
|
|
|
@ -20,11 +20,9 @@ export-env {
|
|||
((ls $"($env.MSVS_ROOT)/VC/Tools/MSVC/*").name.0 | str replace -a '\\' '/')
|
||||
})
|
||||
|
||||
$env.MSVS_MSDK_ROOT = (REG QUERY 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' /v "InstallationFolder" | str replace '(.|\n)+REG_SZ\s+(.+)' "$2")
|
||||
$env.MSVS_MSDK_ROOT = ($env.MSVS_MSDK_ROOT | str replace -a '\\' '/')
|
||||
$env.MSVS_MSDK_ROOT = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder | get value)
|
||||
|
||||
$env.MSVS_MSDK_VER = (REG QUERY 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' /v "ProductVersion" | str replace '(.|\n)+REG_SZ\s+(.+)' "$2")
|
||||
$env.MSVS_MSDK_VER = $"($env.MSVS_MSDK_VER).0"
|
||||
$env.MSVS_MSDK_VER = (registry query --hklm 'SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' ProductVersion | get value) + ".0"
|
||||
|
||||
$env.MSVS_INCLUDE_PATH = ([
|
||||
$"($env.MSVS_ROOT)/Include/($env.MSVS_MSDK_VER)/cppwinrt/winrt",
|
||||
|
@ -43,7 +41,7 @@ export def-env activate [
|
|||
--sdk (-s): string = "latest" # Version of Windows SDK, must be "latest" or a valid version string
|
||||
] {
|
||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||
echo "Either Microsoft Visual Studio or MSVC is valid."
|
||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -57,19 +55,19 @@ export def-env activate [
|
|||
})
|
||||
|
||||
if (($fh != "x64") and ($fh != "x86")) {
|
||||
echo $"Wrong host architecture specified: ($fh)."
|
||||
print $"Wrong host architecture specified: ($fh)."
|
||||
help n_msvc activate
|
||||
return
|
||||
}
|
||||
|
||||
if (($ft != "x64") and ($ft != "x86")) {
|
||||
echo $"Wrong target architecture specified: ($ft)."
|
||||
print $"Wrong target architecture specified: ($ft)."
|
||||
help n_msvc activate
|
||||
return
|
||||
}
|
||||
|
||||
if not ($"($env.MSVS_MSDK_ROOT)bin/($fs)" | path exists) {
|
||||
echo $"Invalid Windows SDK version specified: ($fs)."
|
||||
print $"Invalid Windows SDK version specified: ($fs)."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -84,6 +82,7 @@ export def-env activate [
|
|||
$"($env.MSVS_ROOT)/Common7/Tools/devinit",
|
||||
$"($env.MSVS_ROOT)/MSBuild/Current/bin",
|
||||
$"($env.MSVS_ROOT)/MSBuild/Current/bin/Roslyn",
|
||||
$"($env.MSVS_ROOT)/Team Tools/DiagnosticsHub/Collector",
|
||||
$"($env.MSVS_ROOT)/Team Tools/Performance Tools",
|
||||
$"($env.MSVS_MSVC_ROOT)/bin/Host($fh)/($ft)",
|
||||
$"($env.MSVS_MSDK_ROOT)bin/($ft)",
|
||||
|
@ -125,11 +124,18 @@ export def-env activate [
|
|||
INCLUDE: $env.MSVS_INCLUDE_PATH,
|
||||
LIB: $lib_path
|
||||
}
|
||||
|
||||
hide-env MSVS_BASE_PATH
|
||||
hide-env MSVS_ROOT
|
||||
hide-env MSVS_MSVC_ROOT
|
||||
hide-env MSVS_MSDK_ROOT
|
||||
hide-env MSVS_MSDK_VER
|
||||
hide-env MSVS_INCLUDE_PATH
|
||||
}
|
||||
|
||||
export def-env deactivate [] {
|
||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||
echo "Either Microsoft Visual Studio or MSVC is valid."
|
||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -137,4 +143,7 @@ export def-env deactivate [] {
|
|||
Path: $env.MSVS_BASE_PATH,
|
||||
PATH: $env.MSVS_BASE_PATH
|
||||
}
|
||||
|
||||
hide-env INCLUDE
|
||||
hide-env LIB
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue