From 554cb3181908abbc24fdd7e7bc7f2d8243a0b64f Mon Sep 17 00:00:00 2001 From: Christofer <77406318+csc530@users.noreply.github.com> Date: Sun, 7 Apr 2024 08:46:35 -0400 Subject: [PATCH 01/75] add windows compatibility for command not found hook (#811) the hook (did_you_mean.nu) had stopped working for me recently, I added an if branch for Windows to use their `Path` env var (not `PATH`) and only list files that match in the `PATHEXT` env var to resolve my issue --- .../nu-hooks/command_not_found/did_you_mean.nu | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/nu-hooks/nu-hooks/command_not_found/did_you_mean.nu b/nu-hooks/nu-hooks/command_not_found/did_you_mean.nu index acfa9c8b..3ab6f828 100644 --- a/nu-hooks/nu-hooks/command_not_found/did_you_mean.nu +++ b/nu-hooks/nu-hooks/command_not_found/did_you_mean.nu @@ -18,9 +18,18 @@ # ``` {|cmd| let commands_in_path = ( - $env.PATH | each {|directory| - if ($directory | path exists) { - ls $directory | get name | path parse | update parent "" | path join + if ($nu.os-info.name == windows) { + $env.Path | each {|directory| + if ($directory | path exists) { + let cmd_exts = $env.PATHEXT | str downcase | split row ';' | str trim --char . + ls $directory | get name | path parse | where {|it| $cmd_exts | any {|ext| $ext == ($it.extension | str downcase)} } | get stem + } + } + } else { + $env.PATH | each {|directory| + if ($directory | path exists) { + ls $directory | get name | path parse | update parent "" | path join + } } } | flatten From c30efc727b99ee75ea0140375cf4651268fbe36a Mon Sep 17 00:00:00 2001 From: Christofer <77406318+csc530@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:09:04 -0400 Subject: [PATCH 02/75] add missing scoop completions (#812) I added the missing shims, alias, and help commands for the scoop completer (#483) I also updated the deprecated `rootPath` and `globalPath` config names for the config command --- custom-completions/scoop/scoop-completions.nu | 116 +++++++++++++++++- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/custom-completions/scoop/scoop-completions.nu b/custom-completions/scoop/scoop-completions.nu index db909aae..12fba6ab 100644 --- a/custom-completions/scoop/scoop-completions.nu +++ b/custom-completions/scoop/scoop-completions.nu @@ -91,18 +91,37 @@ def scoopShimBuilds [] { [ 'kiennq', 'scoopcs', '71'] } +def scoopCommands [] { + scoop help | lines --skip-empty | skip 5 | parse '{value} {description}' | str trim +} + +def scoopAliases [] { + scoop alias list | lines --skip-empty | skip 2 | parse '{name} {path}' | get name +} + def batStyles [] { [ 'default', 'auto', 'full', 'plain', 'changes', 'header', 'header-filename', 'header-filesize', 'grid', 'rule', 'numbers', 'snip' ] } +def scoopShims [] { + let localShimDir = if ('SCOOP' in $env) { [ $env.SCOOP, 'shims' ] | path join } else if (scoop config root_path | path exists) { scoop config root_path } else { [ $env.USERPROFILE, 'scoop', 'shims' ] | path join } + let localShims = if ($localShimDir | path exists) { ls $localShimDir | get name | path parse | select stem extension | where extension == shim | get stem } else { [] } + + let globalShimDir = if ('SCOOP_GLOBAL' in $env) { [ $env.SCOOP_GLOBAL, 'shims' ] | path join } else if (scoop config global_path | path exists) { scoop config global_path } else { [ $env.ProgramData, 'scoop', 'shims' ] | path join } + let globalShims = if ($globalShimDir | path exists) { ls $globalShimDir | get name | path parse | select stem extension | where extension == shim | get stem } else { [] } + + $localShims | append $globalShims | uniq | sort +} + ################################################################ # scoop ################################################################ # Windows command line installer export extern "scoop" [ - --help(-h) # Show help for this command. - --version(-v) # Show current scoop and added buckets versions + alias?: string@scoopCommands # avaible scoop commands and aliases + --help(-h) # Show help for this command. + --version(-v) # Show current scoop and added buckets versions ] ################################################################ @@ -194,6 +213,87 @@ export extern "scoop status" [ --local(-l) # Checks the status for only the locally installed apps, and disables remote fetching/checking for Scoop and buckets ] +################################################################ +# scoop help +################################################################ + +# Show help for scoop +export extern "scoop help" [ + --help(-h) # Show help for this command. + + command?: string@scoopCommands # Show help for the specified command +] + +################################################################ +# scoop alias +################################################################ + +# Add, remove or list Scoop aliases +export extern "scoop alias" [ + --help(-h) # Show help for this command. +] + +# add an alias +export extern "scoop alias add" [ + name: string # name of the alias + command: string # scoop command + description: string # description of the alias +] + +# list all aliases +export extern "scoop alias list" [ + --verbose(-v) # Show alias description and table headers (works only for 'list') +] + +# remove an alias +export extern "scoop alias rm" [ + ...name: string@scoopAliases # alias that will be removed +] + + +################################################################ +# scoop shim +################################################################ + +# Manipulate Scoop shims +export extern "scoop shim" [ + --help(-h) # Show help for this command. +] + +# add a custom shim +export extern "scoop shim add" [ + shim_name: string # name of the shim + command_path: path # path to executable + ...cmd_args # additional command arguments + --global(-g) # Manipulate global shim(s) +] + +# remove shims (CAUTION: this could remove shims added by an app manifest) +export extern "scoop shim rm" [ + ...shim_name: string@scoopShims # shim that will be removed + --global(-g) # Manipulate global shim(s) +] + +# list all shims or matching shims +export extern "scoop shim list" [ + pattern?: string # list only matching shims + --global(-g) # Manipulate global shim(s) +] + +# show a shim's information +export extern "scoop shim info" [ + shim_name: string@scoopShims # shim info to retrieve + --global(-g) # Manipulate global shim(s) +] + +# alternate a shim's target source +export extern "scoop shim alter" [ + shim_name: string@scoopShims # shim that will be alternated + --global(-g) # Manipulate global shim(s) +] + + + ################################################################ # scoop which ################################################################ @@ -303,12 +403,12 @@ export extern "scoop config shim" [ ] # Path to Scoop root directory. -export extern "scoop config rootPath" [ +export extern "scoop config root_path" [ value?: directory ] # Path to Scoop root directory for global apps. -export extern "scoop config globalPath" [ +export extern "scoop config global_path" [ value?: directory ] @@ -480,6 +580,12 @@ export extern "scoop search" [ # scoop cache ... ################################################################ +# Show the download cache +export extern "scoop cache" [ + ...?apps: string@scoopInstalledAppsWithStar # apps in question + --help(-h) # Show help for this command. +] + # Show the download cache export extern "scoop cache show" [ ...?apps: string@scoopInstalledAppsWithStar # apps in question @@ -510,7 +616,7 @@ export extern "scoop download" [ ################################################################ def scoopKnownBuckets [] { - [ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games" ] + [ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games" ] } def scoopInstalledBuckets [] { From b1019dab189c8fee3435e1e291f18de0b6b64c97 Mon Sep 17 00:00:00 2001 From: Edward DeVries Date: Thu, 11 Apr 2024 09:00:04 -0400 Subject: [PATCH 03/75] panache-git: do not print stderr from Git commands (#813) Nushell 0.92 changed how external commands operate in pipelines: https://www.nushell.sh/blog/2024-04-02-nushell_0_92_0.html After updating to Nushell 0.92, panache-git would print errors when the current working directory was not a Git repository: "fatal: not a git repository (or any of the parent directories): .git" This change properly handles stderr from Git commands according to Nushell's updated external command behavior. Also, Nushell 0.91 introduced "is-not-empty", so places in the code where a string was checked for being not-empty or not-contains were simplified a bit. Finally, the main command in the module was renamed to "main" to make it simpler to import and use in config. --- modules/prompt/panache-git.nu | 36 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/modules/prompt/panache-git.nu b/modules/prompt/panache-git.nu index 0ae9068f..0f1ef47c 100644 --- a/modules/prompt/panache-git.nu +++ b/modules/prompt/panache-git.nu @@ -4,20 +4,20 @@ # Quick Start: # - Download this file (panache-git.nu) # - In your Nushell config: -# - Import the panache-git command from the panache-git.nu module file +# - Import the main command from the panache-git.nu module file # - Set panache-git as your prompt command # - Disable the separate prompt indicator by setting it to an empty string # - For example, with this file in your home directory: -# use ~/panache-git.nu panache-git -# $env.PROMPT_COMMAND = { panache-git } -# $env.PROMPT_INDICATOR = { "" } +# use ~/panache-git.nu main +# $env.PROMPT_COMMAND = {|| panache-git } +# $env.PROMPT_INDICATOR = {|| "" } # - Restart Nushell # # For more documentation or to file an issue, see https://github.com/ehdevries/panache-git # An opinionated Git prompt for Nushell, styled after posh-git -export def prompt-with-panache [] { +export def main [] { let prompt = ($'(current-dir) (repo-styled)' | str trim) $'($prompt)> ' } @@ -30,7 +30,7 @@ export def current-dir [] { do --ignore-errors { $current_dir | path relative-to $nu.home-path } | str join ) - let in_sub_dir_of_home = ($current_dir_relative_to_home | is-empty | nope) + let in_sub_dir_of_home = ($current_dir_relative_to_home | is-not-empty) let current_dir_abbreviated = (if $in_sub_dir_of_home { $'~(char separator)($current_dir_relative_to_home)' | str replace -ar '\\' '/' @@ -43,7 +43,7 @@ export def current-dir [] { # Get repository status as structured data export def repo-structured [] { - let in_git_repo = (do --ignore-errors { git rev-parse --abbrev-ref HEAD } | is-empty | nope) + let in_git_repo = (do { git rev-parse --abbrev-ref HEAD } | complete | get stdout | is-not-empty) let status = (if $in_git_repo { git --no-optional-locks status --porcelain=2 --branch | lines @@ -55,8 +55,7 @@ export def repo-structured [] { $status | where ($it | str starts-with '# branch.head') | first - | str contains '(detached)' - | nope + | str contains --not '(detached)' } else { false }) @@ -86,8 +85,7 @@ export def repo-structured [] { $status | where ($it | str starts-with '# branch.upstream') | str join - | is-empty - | nope + | is-not-empty } else { false }) @@ -96,8 +94,7 @@ export def repo-structured [] { $status | where ($it | str starts-with '# branch.ab') | str join - | is-empty - | nope + | is-not-empty } else { false }) @@ -133,8 +130,7 @@ export def repo-structured [] { $status | where ($it | str starts-with '1') or ($it | str starts-with '2') | str join - | is-empty - | nope + | is-not-empty } else { false }) @@ -143,8 +139,7 @@ export def repo-structured [] { $status | where ($it | str starts-with '?') | str join - | is-empty - | nope + | is-not-empty } else { false }) @@ -153,8 +148,7 @@ export def repo-structured [] { $status | where ($it | str starts-with 'u') | str join - | is-empty - | nope + | is-not-empty } else { false }) @@ -380,10 +374,6 @@ export def repo-styled [] { # Helper commands to encapsulate style and make everything else more readable -def nope [] { - each { |it| $it == false } -} - def bright-cyan [] { each { |it| $"(ansi -e '96m')($it)(ansi reset)" } } From 2d3406b5269cf2880667045c7408e06ad9bd4836 Mon Sep 17 00:00:00 2001 From: Miles Cranmer Date: Fri, 12 Apr 2024 00:56:18 +0100 Subject: [PATCH 04/75] Fix non-exported completions (#815) ack, as, and tar were not exported --- custom-completions/ack/ack-completions.nu | 2 +- custom-completions/as/as-completions.nu | 4 ++-- custom-completions/tar/tar-completions.nu | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom-completions/ack/ack-completions.nu b/custom-completions/ack/ack-completions.nu index 076f45dd..8478a268 100644 --- a/custom-completions/ack/ack-completions.nu +++ b/custom-completions/ack/ack-completions.nu @@ -1,6 +1,6 @@ # copied from auto-generated completions -extern "ack" [ +export extern "ack" [ --ignore-case(-i) # Ignore case --smart-case # Ignore case when pattern contains no uppercase --no-smart-case # Dont ignore case diff --git a/custom-completions/as/as-completions.nu b/custom-completions/as/as-completions.nu index 39d737b4..b4a3e974 100644 --- a/custom-completions/as/as-completions.nu +++ b/custom-completions/as/as-completions.nu @@ -1,5 +1,5 @@ # Omit false conditionals -extern "as" [ +export extern "as" [ --alternate # Initially turn on alternate macro syntax --nocompress-debug-sections # Dont compress DWARF debug sections --execstack # Require executable stack for this object @@ -33,7 +33,7 @@ extern "as" [ ] # Generate ELF common symbols with STT_COMMON type -extern "as yes no" [ +export extern "as yes no" [ --alternate # Initially turn on alternate macro syntax --nocompress-debug-sections # Dont compress DWARF debug sections --execstack # Require executable stack for this object diff --git a/custom-completions/tar/tar-completions.nu b/custom-completions/tar/tar-completions.nu index a6acb139..84446004 100644 --- a/custom-completions/tar/tar-completions.nu +++ b/custom-completions/tar/tar-completions.nu @@ -1,5 +1,5 @@ # Append archive to archive -extern "tar" [ +export extern "tar" [ --concatenate(-A) # Append archive to archive --create(-c) # Create archive --compare(-d) # Compare archive and filesystem From 0d665a71ec6be0ca7e1280d204dcd65da55dd915 Mon Sep 17 00:00:00 2001 From: Miles Cranmer Date: Fri, 12 Apr 2024 12:26:51 +0100 Subject: [PATCH 05/75] fix: prefix conda commands with `conda` (#816) I wasn't sure if this was on purpose or not but the conda environments were simply "activate" and "deactivate" instead of "conda activate" and "conda deactivate" as they would be normally in bash/zsh. Due to the potential name conflicts I think it's better to leave these as the more specific `conda activate` and let the user define an alias in their file with `alias activate = conda activate` --- modules/virtual_environments/conda.nu | 4 ++-- modules/virtual_environments/nu_conda/nu_conda.nu | 6 +++--- modules/virtual_environments/nu_conda_2/conda.nu | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/virtual_environments/conda.nu b/modules/virtual_environments/conda.nu index 70fd4f53..270be37a 100644 --- a/modules/virtual_environments/conda.nu +++ b/modules/virtual_environments/conda.nu @@ -1,5 +1,5 @@ # Activate conda environment -export def --env activate [ +export def --env "conda activate" [ env_name?: string@'nu-complete conda envs' # name of the environment ] { let conda_info = (conda info --envs --json | from json) @@ -73,7 +73,7 @@ export def --env activate [ } # Deactivate currently active conda environment -export def --env deactivate [] { +export def --env "conda deactivate" [] { let path_name = if "PATH" in $env { "PATH" } else { "Path" } $env.$path_name = $env.CONDA_OLD_PATH diff --git a/modules/virtual_environments/nu_conda/nu_conda.nu b/modules/virtual_environments/nu_conda/nu_conda.nu index 89a9b4d0..4383c043 100644 --- a/modules/virtual_environments/nu_conda/nu_conda.nu +++ b/modules/virtual_environments/nu_conda/nu_conda.nu @@ -22,7 +22,7 @@ export-env { $env.CONDA_CURR = null } -export def --env activate [name: string] { +export def --env "conda activate" [name: string] { if ($env.CONDA_ROOT | is-empty) { print "Neither Conda nor Mamba is valid." return @@ -44,7 +44,7 @@ export def --env activate [name: string] { load-env ({CONDA_CURR: $name} | merge $new_path) } -export def --env deactivate [] { +export def --env "conda deactivate" [] { if ($env.CONDA_ROOT | is-empty) { print "Neither Conda nor Mamba is valid." return @@ -55,7 +55,7 @@ export def --env deactivate [] { load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH} } -export def --env list [] { +export def --env "conda list" [] { $env.CONDA_ENVS | flatten | transpose | diff --git a/modules/virtual_environments/nu_conda_2/conda.nu b/modules/virtual_environments/nu_conda_2/conda.nu index ccbd3e06..cd206a30 100644 --- a/modules/virtual_environments/nu_conda_2/conda.nu +++ b/modules/virtual_environments/nu_conda_2/conda.nu @@ -21,7 +21,7 @@ def --env load-conda-info-env [] { } # Activate conda environment -export def --env activate [ +export def --env "conda activate" [ env_name: string@'nu-complete conda envs' = "base" # name of the environment ] { load-conda-info-env @@ -94,7 +94,7 @@ export def --env activate [ } # Deactivate currently active conda environment -export def --env deactivate [] { +export def --env "conda deactivate" [] { let path_name = if "PATH" in $env { "PATH" } else { "Path" } $env.$path_name = $env.CONDA_OLD_PATH From f0975a9458bfd49bd13b295c9182128c8a5fb69a Mon Sep 17 00:00:00 2001 From: Zuruh Date: Sat, 13 Apr 2024 04:09:00 +0200 Subject: [PATCH 06/75] =?UTF-8?q?=E2=9C=A8=20add=20composer=20completions?= =?UTF-8?q?=20(#817)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented definitions for all composer 2.7 base commands with flags, arguments, and descriptions. Also add completions when a set of values is expected 🙂 --- .../composer/composer-completions.nu | 551 ++++++++++++++++++ custom-completions/composer/readme.md | 4 + 2 files changed, 555 insertions(+) create mode 100644 custom-completions/composer/composer-completions.nu create mode 100644 custom-completions/composer/readme.md diff --git a/custom-completions/composer/composer-completions.nu b/custom-completions/composer/composer-completions.nu new file mode 100644 index 00000000..c4ed7464 --- /dev/null +++ b/custom-completions/composer/composer-completions.nu @@ -0,0 +1,551 @@ +# Written for composer v2.7.0 + +def "nu-complete composer installed-packages" [] { + cat composer.lock | from json | get packages | each {get name} +} + +def "nu-complete composer installation-modes" [] { + [ + { value: 'dist', description: 'Install from package dist' } + { value: 'source', description: 'Install from package source and include VSC information' } + { value: 'auto', description: 'Use source for dev versions and dist for the rest' } + ] +} + +def "nu-complete composer audit-formats" [] { + ['table' 'plain' 'json' 'summary'] +} + +def "nu-complete composer commands" [] { + composer list --format json | + from json | + get commands | + filter {|cmd| not $cmd.hidden} | + each {|cmd| {value: $cmd.name, description: $cmd.description}} +} + +# Composer is a tool for dependency management in PHP. +export extern "composer" [ + --help(-h) # Display help for the given command. When no command is given display help for the list command. + --quiet(-q) # Do not output any message. + --version(-V) # Display the application version. + --ansi # Force ANSI output. + --no-ansi # Disable ANSI output. + --no-interaction(-n) # Do not ask any interactive question. + --profile # Display timing and memory usage information. + --no-plugins # Whether to disable plugins. + --no-scripts # Skips the execution of all scripts defined in composer.json file. + --working-dir(-d): string # If specified, use the given directory as working directory. + --no-cache # Prevent use of the cache. + --verbose(-v) # Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug. +] + +def "nu-complete composer command-description-output-formats" [] { + ['txt', 'xml', 'json', 'md'] +} + +# Shows a short information about Composer. +export extern "composer about" [] + +def "nu-complete composer archive-formats" [] { + ['tar' 'tar.gz' 'tar.bz2' 'zip'] +} + +# Creates an archive of this composer package. +export extern "composer archive" [ + --format(-f): string@"nu-complete composer archive-formats" # Format of the resulting archive: tar, tar.gz, tar.gz2, zip. [default: "tar"] + --dir: string # Write the archive to this directory. + --file: string # Write the archive with the given file name. Note that the format will be appended. + --ignore-filters # Ignore filters when saving package. + + package?: string # The package to archive instead of the current project. + version?: string # A versions constraint to find the package to archive. +] + +# Checks for security vulnerability advisories for the installed packages. +export extern "composer audit" [ + --no-dev # Disables auditing of require-dev packages. + --format(-f): string@"nu-complete composer audit-formats" # Output format. Must be "table", "plain", "json", or "summary". [default: "table"] + --locked # Audit based on the lock file instead of the installed packages. +] + +# Opens the package's repository URL or homepage in your browser. +export extern "composer browse" [ + --homepage(-H) # Open the homepage instead of the repository URL. + --show(-s) # Only show the homepage or repository URL. + + ...packages: string # Package(s) to browse to. +] + +# Increases the lower limit of your composer.json requirements to the currently installed versions. +export extern "composer bump" [ + --dev-only(-D) # Only bump requirements in "require-dev". + --no-dev-only(-R) # Only bump requirements in "require" + --dry-run # Outputs the packages to bump, but will not execute anything. + + ...packages: string@"nu-complete composer installed-packages" # Optional package name(s) to restrict which packages are bumped. +] + +def "nu-complete composer platform-reqs-formats" [] { + ['text' 'json'] +} + +# Check that platform requirements are satisfied. +export extern "composer check-platform-reqs" [ + --no-dev # Disables checking of require-dev packages requirements. + --lock # Checks requirements only from the lock file, not from installed packages. + --format(-f): string@"nu-complete composer platform-reqs-formats" # Format of the output: text or json. [default: "text"] +] + +# [clearcache|cc] Clears composer's internal package cache. +export extern "composer clear-cache" [ + --gc # Only run garbage collection, not a full cache clear. +] + +def "nu-complete composer completion-shells" [] { + ['bash'] +} + +# Dump the shell completion script. +export extern "composer completion" [ + --debug # Tail the completion debug log. + shell: string@"nu-complete composer completion-shells" = 'bash' # The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given. +] + +# Sets config options. +export extern "composer config" [ + --global(-g) # Apply command to the global config file. + --editor(-e) # Open editor. + --auth(-a) # Affect auth config file (only used for --editor). + --unset # Unset the given setting-key. + --list(-l) # List configuration settings. + --file(-f): string # If you want to choose a different composer.json or config.json. + --absolute # Returns absolute paths when fetching *-dir config values instead of relative. + --json(-j) # JSON decode the setting value, to be used with extra.* keys. + --merge(-m) # Merge the setting value with the current value, to be used with extra.* keys instead of prepending it (highest priority). + --append # When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority). + --source # Display where the config value is loaded from. + + settings_key: string + settings_value?: string +] + +# Creates a new project from a package into a given directory. +export extern "composer create-project" [ + --stability(-s) # Minimum-stability allowed (unless as version is specified). + + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --repository: string # Add custom repositories to look the package up, either by URL or using JSON arrays (multiple values allowed). + --add-repository # Add the custom repository in the composer.json. If a lockfile is present it will be deleted and an update will be run instead of install. + + --no-dev # Disables installation of require-dev packages. + --no-scripts # Skips the execution of all scripts defined in composer.json file. + --no-progress # Do not output download progress. + --no-secure-http # Disable the secure-http config option temporarily while installing the root package. Use at your own risk. Using this flag is a bad idea. + --keep-vcs # Whether to prevent deleting the vcs folder. + --remove-vcs # Whether to force deletion of the vcs folder without prompting. + --no-install # Whether to skip installation of the package dependencies. + --no-audit # Whether to skip auditing of the installed package dependencies (can also be set via the COMPOSER_NO_AUDIT=1 env var). + --audit-format: string@"nu-complete composer audit-formats" # Audit output format. Must be "table", "plain", "json" or "summary". [default: "summary"] + --ignore-platform-req: string # Ignore a specific platform requirement (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + --ask # Whether to ask for project directory. + + package?: string # Package name to be installed. + directory?: string # Directory where the files should be created. + version?: string # Version, will default to latest. +] + +# [why] Shows which packages cause the given package to be installed. +export extern "composer depends" [ + --recursive(-r) # Recursively resolves up to the root package. + --tree(-t) # Prints the results as a nested tree. + --locked # Read dependency information from composer.lock. + + package: string # Package to inspect. +] + +# Diagnoses the system to identify common errors. +export extern "composer diagnose" [] + +# [dumpautoload] Dumps the autoloader. +export extern "composer dump-autoload" [ + --optimize(-o) # Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables `--optimize`. + --apcu # Use APCu to cache found/not-found classes. + --apcu-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu + + --dry-run # Outputs the operations but will not execute anything. + --dev # Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state. + --no-dev # Disables autoload-dev rules. Composer will by default inf er this automatically according to the last install or update --no-dev state. + + --ignore-platform-req: string # Ignore a specific platform requirement (php & ext- package es). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + --strict-psr # Return a failed status code (1) if PSR-4 or PSR-0 mapping errors are present. Requires --optimize to work. +] + +def "nu-complete composer exec-scripts" [] { + composer exec --list | + split row (char newline) | + skip 1 | + str trim --char '-' | + str trim +} + +# Executes a vendored binary/script. +export extern "composer exec" [ + --list(-l) # List all executable scripts. + + script?: string@"nu-complete composer exec-scripts" # The binary to run, e.g. phpunit. + ...args: string # Arguments to pass to the binary. Use `--` to separate from composer arguments. +] + +def "nu-complete composer fund-formats" [] { + ['text' 'json'] +} + +# Discover how to help fund the maintenance of your dependencies. +export extern "composer fund" [ + --format(-f): string@"nu-complete composer fund-formats" # Format of the output: text or json. [default: "text"] +] + +# Allows running commands in the global composer dir ($COMPOSER_HOME). +export extern "composer global" [ + command_name: string@"nu-complete composer commands" + ...args: string +] + +# Display help for a command. +export extern "composer help" [ + --raw # To output raw command help. + --format: string@"nu-complete composer command-description-output-formats" # The output format (txt, xml, json, or md) [default: "txt"]. + + command?: string@"nu-complete composer commands" # The command name. [default: "help"] +] + +def "nu-complete composer project-types" [] { + ['library' 'project' 'metapackage' 'composer-plugin'] +} + +# Creates a basic composer.json file in current directory. +export extern "composer init" [ + --name: string # Name of the package. + --description: string # Description of package. + --author: string # Author name of package. + --type: string@"nu-complete composer project-types" # Type of package (e.g. library, project, metapackage, composer-plugin). + --homepage: string # Homepage of package. + --require: string # Package to require with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0" (multiple values allowed). + --require-dev: string #-DEV Package to require for development with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0" (multiple values allowed). + -s, --stability: string # Minimum stability (empty or one of: stable, RC, beta, alpha, dev). + -l, --license: string # License of package. + --repository: string # Add custom repositories, either by URL or using JSON arrays (multiple values allowed). + --autoload(-a): string # Add PSR-4 autoload mapping. Maps your package's namespace to the provided directory. (Expects a relative path, e.g. src/). +] + +# [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json +export extern "composer install" [ + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --dry-run # Outputs the operations but will not execute anything (implicitly enables --verbose). + --download-only # Download only, do not install packages. + --no-dev # Disables installation of require-dev packages. + --no-autoloader # Skips autoloader generation. + --no-progress # Do not output download progress. + + --audit # Run an audit after installation is complete. + --audit-format: string@"nu-complete composer audit-formats" # Audit output format. Must be "table", "plain", "json", or "summary". [default: "summary"] + + --optimize-autoloader(-o) # Optimize autoloader during autoloader dump. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables --apcu-autoloader + --apcu-autoloader # Use APCu to cache found/not-found classes. + --apcu-autoloader-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader. + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). +] + +def "nu-complete composer licenses-formats" [] { + ['text' 'json' 'summary'] +} + +# Shows information about licenses of dependencies. +export extern "composer licenses" [ + --format(-f): string@"nu-complete composer licenses-formats" # Format of the output: text, json or summary. [default: "text"] + --no-dev # Disables search in require-dev packages. +] + +# List commands +export extern "composer list" [ + --raw # To output raw command list. + --format: string@"nu-complete composer command-description-output-formats" # The output format (txt, xml, json, or md) [default: "txt"]. + --short # To skip describing commands' arguments. +] + +def "nu-complete composer show-formats" [] { + ['text' 'json'] +} + +# Shows a list of installed packages that have updates available, including their latest version. +export extern "composer outdated" [ + --outdated(-o) # Show only packages that are outdated (this is the default, but present here for compat with `show`) + --all(-a) # Show all installed packages with their latest versions + --locked # Shows updates for packages from the lock file, regardless of what is currently in vendor dir + --direct(-D) # Shows only packages that are directly required by the root package + --strict # Return a non-zero exit code when there are outdated packages + --major-only(-M) # Show only packages that have major SemVer-compatible updates. + --minor-only(-m) # Show only packages that have minor SemVer-compatible updates. + --patch-only(-p) # Show only packages that have patch SemVer-compatible updates. + --sort-by-age(-A) # Displays the installed version's age, and sorts packages oldest first. + --format(-f): string@"nu-complete composer show-formats" # Format of the output: text or json [default: "text"] + --ignore: string # Ignore specified package(s). Can contain wildcards (*). Use it if you don't want to be informed about new versions of some packages. (multiple values allowed) + --no-dev # Disables search in require-dev packages. + + --ignore-platform-req: string # Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). Use with the --outdated option + + package?: string # Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead. +] + +# [why-not] Shows which packages prevent the given package from being installed +export extern "composer prohibits" [ + --recursive(-r) # Recursively resolves up to the root package. + --tree(-t) # Prints the results as a nested tree. + --locked # Read dependency information from composer.lock. + + package: string # Package to inspect. + version?: string # Version constraint, which version you expected to be installed. +] + +# Uninstalls and reinstalls the given package names. +export extern "composer reinstall" [ + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --no-autoloader # Skips autoloader generation. + --no-progress # Do not output download progress. + + --optimize-autoloader(-o) # Optimize autoloader during autoloader dump. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables --apcu-autoloader + --apcu-autoloader # Use APCu to cache found/not-found classes. + --apcu-autoloader-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader. + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + + ...packages: string@"nu-complete composer installed-packages" # List of package names to reinstall, can include a wildcard (*) to match any substring. +] + +# [rm] Removes a package from the require or require-dev +export extern "composer remove" [ + --dev # Removes a package from the require-dev section. + --dry-run # Outputs the operations but will not execute anything (implicitly enables --verbose). + + --no-progress # Do not output download progress. + --no-update # Disables the automatic update of the dependencies (implies --no-install). + --no-install # Skip the install step after update the composer.lock file. + --no-audit # Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var). + --audit-format: string@"nu-complete composer audit-formats" # Audit output format. Must be "table", "plain", "json", or "summary". [default: "summary"] + --update-no-dev # Run the dependency update with the --no-dev option. + --update-with-dependencies(-w) # Allows inherited dependencies to be updated, except those that are root requirements. + --update-with-all-dependencies(-W) # Allows all inherited dependencies to be updated, including those that are root requirements. + --with-dependencies # Alias for --update-with-dependencies + --with-all-dependencies # Alias for --update-with-all-dependencies + + --minimal-changes(-M) # During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var). + + --unused # Remove all packages which are locked but not required by any other package. + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + + --optimize-autoloader(-o) # Optimize autoloader during autoloader dump. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables --apcu-autoloader + --apcu-autoloader # Use APCu to cache found/not-found classes. + --apcu-autoloader-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader. + + ...packages: string@"nu-complete composer installed-packages" # Packages that should be removed. +] + +# [r|req] Adds required packages to your composer.json and installs them +export extern "composer require" [ + --dev # Add requirement to require-dev. + --dry-run # Outputs the operations but will not execute anything (implicitly enables --verbose). + + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --fixed # Write fixed version to the composer.json. + + --no-progress # Do not output download progress. + --no-update # Disables the automatic update of the dependencies (implies --no-install). + --no-install # Skip the install step after update the composer.lock file. + --no-audit # Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var). + --audit-format: string@"nu-complete composer audit-formats" # Audit output format. Must be "table", "plain", "json", or "summary". [default: "summary"] + --update-no-dev # Run the dependency update with the --no-dev option. + --update-with-dependencies(-w) # Allows inherited dependencies to be updated, except those that are root requirements. + --update-with-all-dependencies(-W) # Allows all inherited dependencies to be updated, including those that are root requirements. + --with-dependencies # Alias for --update-with-dependencies + --with-all-dependencies # Alias for --update-with-all-dependencies + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + + --prefer-stable # Prefer stable versions of dependencies (can also be set via the COMPOSER_PREFER_STABLE=1 env var) + --prefer-lowest # Prefer lowest versions of dependencies (can also be set via the COMPOSER_PREFER_LOWEST=1 env var) + + --minimal-changes(-M) # During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var). + --sort-packages # Sorts packages when adding/updateing a new dependency. + + --optimize-autoloader(-o) # Optimize autoloader during autoloader dump. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables --apcu-autoloader + --apcu-autoloader # Use APCu to cache found/not-found classes. + --apcu-autoloader-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader. + + ...packages: string +] + +def "nu-complete composer scripts" [] { + do { composer run --list } | + complete | + get stdout | + split row (char newline) | + parse ' {value} {description}' | + str trim +} + +# [run] Runs the scripts defined in composer.json. +export extern "composer run-script" [ + --timeout: int # Sets script timeout in seconds, or 0 for never. + --dev # Sets the dev mode. + --list(-l) # List scripts. + script?: string@"nu-complete composer scripts" # Script name to run. + ...args: string +] + +def "nu-complete composer search-formats" [] { + ['text' 'json'] +} + +# Searches for packages +export extern "composer search" [ + --only-name(-N) # Search only in package name + --only-vendor(-O) # Search only for vendor / organization names, returns only "vendor" as result. + --type(-t): string@"nu-complete composer project-types" # Search for a specific package type. + --format(-f): string@"nu-complete composer search-formats" # Format of the output: text or json. [default: "text"] + + ...tokens: string # Tokens to search for. +] + +## TODO: find a way to specify --1 --2 --2.2 flags for self-update command +# --1 # Force an update to the stable channel, but only use 1.x versions +# --2 # Force an update to the stable channel, but only use 2.x versions +# --2.2 # Force an update to the stable channel, but only use 2.2.x LTS versions + +# [selfupdate] Updates composer.phar to the latest version. +export extern "composer self-update" [ + --rollback(-r) # Revert to an older installation of composer + --clean-backups # Delete old backups during an update. This makes the current version of compsoer the only backup available after the update. + --no-progress # Do not output download progress. + --update-keys # Prompt user for a key update. + --stable # Force an update to the stable channel. + --preview # Force an update to the preview channel. + --snapshot # Force an update to the snapshot channel. + --set-channel-only # Only store the channel as the default one and then exit. + + version?: string # The version to update to +] + +# [info] Shows information about packages. +export extern "composer show" [ + --outdated(-o) # Show only packages that are outdated (this is the default, but present here for compat with `show`) + --all(-a) # Show all installed packages with their latest versions + --locked # Shows updates for packages from the lock file, regardless of what is currently in vendor dir + --direct(-D) # Shows only packages that are directly required by the root package + --strict # Return a non-zero exit code when there are outdated packages + --major-only(-M) # Show only packages that have major SemVer-compatible updates. + --minor-only(-m) # Show only packages that have minor SemVer-compatible updates. + --patch-only(-p) # Show only packages that have patch SemVer-compatible updates. + --sort-by-age(-A) # Displays the installed version's age, and sorts packages oldest first. + --format(-f): string@"nu-complete composer show-formats" # Format of the output: text or json [default: "text"] + --ignore: string # Ignore specified package(s). Can contain wildcards (*). Use it if you don't want to be informed about new versions of some packages. (multiple values allowed) + --no-dev # Disables search in require-dev packages. + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + + package?: string # Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead. + version?: string # Version constraint, which version you expected to be installed. +] + +# Shows a list of locally modified packages. +export extern "composer status" [] + +# Shows package suggestions. +export extern "composer suggest" [ + --by-package # Groups output by suggesting package (default) + --by-suggestion # Groups output by suggested package + --all(-a) # Show suggestions from all dependencies, including transitive ones + --list # Show only list of suggested package names + --no-dev # Exclude suggestions from require-dev packages + + ...packages: string # Packages that you want to list suggestions from. +] + +# [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file. +export extern "composer update" [ + --with: string # Temporary version constraint to add, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 (multiple values allowed) + + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --dry-run # Outputs the packages to bump, but will not execute anything. + --no-dev # Disables installation of require-dev packages + + --lock # Overwrites the lock file hash to suppress warning about the lock file being out of date without updating package versions. Package metadata like mirrors and URLs are updated if they changed. + + --no-audit # Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var). + --audit-format: string@"nu-complete composer audit-formats" # Audit output format. Must be "table", "plain", "json", or "summary". [default: "summary"] + --update-no-dev # Run the dependency update with the --no-dev option. + --with-dependencies(-w) # Update also dependencies of packages in the argument list, except those which are root requirements. + --with-all-dependencies(-W) # Update also dependencies of packages in the argument list, including those which are root requirements. + + + --optimize-autoloader(-o) # Optimize autoloader during autoloader dump. + --classmap-authoritative(-a) # Autoload classes from the classmap only. Implicitly enables --apcu-autoloader + --apcu-autoloader # Use APCu to cache found/not-found classes. + --apcu-autoloader-prefix: string # Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader. + + --ignore-platform-req: string # Ignore a specific platform requirements (php & ext- packages). (multiple values allowed). + --ignore-platform-reqs # Ignore all platform requirements (php & ext- packages). + + --prefer-source # Forces installation from package sources when possible, including VCS information. + --prefer-dist # Forces installation from package dist (default behavior). + --prefer-install: string@"nu-complete composer installation-modes" # Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest). + + --minimal-changes(-M) # During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var). + + --interactive(-i) # Interactive interface with autocompletion to select the packages to update. + --root-reqs # Restricts the update to your first degree dependencies. + + ...packages: string@"nu-complete composer installed-packages" +] + +# Validates a composer.json and composer.lock. +export extern "composer validate" [ + --no-check-all # Do not validate requires for overly strict/loose constraints. + --check-lock # Check if lock file is up to date (even when config.lock is false). + --no-check-lock # Do not check if lock file is up to date. + --no-check-publish # Do not check for publish errors. + --no-check-version # Do not report a warning if the version field is present. + --with-dependencies(-A) # Also validate the composer.json of all installed dependencies. + --strict # Return a non-zero exit code for warnings as well as errors. + file?: string = "composer.json" +] diff --git a/custom-completions/composer/readme.md b/custom-completions/composer/readme.md new file mode 100644 index 00000000..90fac8d5 --- /dev/null +++ b/custom-completions/composer/readme.md @@ -0,0 +1,4 @@ +# Composer completions + +Nushell extern definitions and completers for [Composer](https://getcomposer.org), the standard package manager for PHP. +The definitions target composer version 2.7 and provide auto-completion for locally installed packages for operations like removing or updating a dependency. From c33c7808fc6a50c359a195563053c43923cfece3 Mon Sep 17 00:00:00 2001 From: zhangym <40376181+zhangymPerson@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:38:45 +0800 Subject: [PATCH 07/75] feat: add mvn completion (#819) --- custom-completions/mvn/README.md | 36 ++++++ custom-completions/mvn/mvn-completions.nu | 139 ++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 custom-completions/mvn/README.md create mode 100644 custom-completions/mvn/mvn-completions.nu diff --git a/custom-completions/mvn/README.md b/custom-completions/mvn/README.md new file mode 100644 index 00000000..7549e492 --- /dev/null +++ b/custom-completions/mvn/README.md @@ -0,0 +1,36 @@ +# Apache maven + +## introduction + +Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by The Apache Software Foundation, where it was formerly part of the Jakarta Project. + +## website + +[https://maven.apache.org/](https://maven.apache.org/) + +## github + +[https://github.com/apache/maven](https://github.com/apache/maven) + +## install + +### download + +[https://maven.apache.org/download.cgi](https://maven.apache.org/download.cgi) + +### install + +```bash +tar -zxvf apache-maven-${version}-bin.tar.gz +mv apache-maven-${version} /usr/local/ +export M2_HOME=/usr/local/apache-maven-${version} +export PATH=$M2_HOME/bin:$PATH +source /etc/profile +mvn -v +``` + +## use maven in nushell + +```bash +source path/to/nu_scripts/custom-completions/mvn/mvn-completions.nu +``` diff --git a/custom-completions/mvn/mvn-completions.nu b/custom-completions/mvn/mvn-completions.nu new file mode 100644 index 00000000..edb74dd4 --- /dev/null +++ b/custom-completions/mvn/mvn-completions.nu @@ -0,0 +1,139 @@ +# Display a help message +extern "mvn" [ + --also-make # If project list is specified, also build projects required by the list + --also-make-dependents # If project list is specified, also build projects that depend on projects on the list + --batch-mode(-B) # Run in non-interactive (batch) mode (disables output color) + --builder(-b) # The id of the build strategy to use + --strict-checksums(-C) # Fail the build if checksums don't match + --lax-checksums(-c) # Warn if checksums don't match + --color # Defines the color mode of the output. Supported are 'auto', 'always', 'never'. + --check-plugin-updates # Ineffective, only kept for backward compatibility + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --encrypt-master-password # Encrypt master security password + --encrypt-password # Encrypt server password + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --fail-at-end # Only fail the build afterwards; allow all non-impacted builds to continue + --fail-fast # Stop at first failure in reactorized builds + --fail-never # NEVER fail the build, regardless of project result + --global-settings # Alternate path for the global settings file + --global-toolchains # Alternate path for the global toolchains file + --help(-h) # Display help information + --log-file(-l) # Log file where all build output will go (disables output color) + --legacy-local-repository # UNSUPPORTED: Use of this option will make Maven invocation fail. + --non-recursive(-N) # Do not recurse into sub-projects + --no-plugin-registry # Ineffective, only kept for backward compatibility + --no-plugin-updates # Ineffective, only kept for backward compatibility + --no-snapshot-updates # Suppress SNAPSHOT updates + --no-transfer-progress # Do not display transfer progress when downloading or uploading + --offline(-o) # Work offline + --activate-profiles(-P) # Comma-delimited list of profiles to activate + --projects # Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path + --quiet(-q) # Quiet output - only show errors + --resume-from # Resume reactor from specified project + --settings(-s) # Alternate path for the user settings file + --toolchains(-t) # Alternate path for the user toolchains file + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --update-snapshots(-U) # Forces a check for missing releases and updated snapshots on remote repositories + --update-plugins # Ineffective, only kept for backward compatibility + --version(-v) # Display version information + --show-version(-V) # Display version information WITHOUT stopping build + --debug(-X) # Produce execution debug output + ...args +] + +# default mvn plugins +# Clean up after the build +extern "mvn clean" [ +] + +# Clean project and Skip test and Install the built artifact into the local repository. +extern "mvn clean install -DskipTests" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Validates the project's POMs +extern "mvn validate" [ + + ...args +] + +# Compiles Java source +extern "mvn compile" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Run project test class +extern "mvn test" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Build and package the project +extern "mvn package" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Useful for integration tests - verifies the existence of certain conditions. +extern "mvn verify" [ + + ...args +] + +# Install the built artifact into the local repository. +extern "mvn install" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Skip test and Install the built artifact into the local repository. +extern "mvn install -DskipTests" [ + --debug(-X) # Produce execution debug output + --define(-D) # Define a user property + --errors(-e) # Produce execution error messages + --file(-f) # Force the use of an alternate POM file (or directory with pom.xml) + --threads(-T) # Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied + --settings(-s) # Alternate path for the user settings file + ...args +] + +# Generate a site for the current project. +extern "mvn site" [ + + ...args +] + +# Deploy the build artifacts to the remote repository. +extern "mvn deploy" [ + --non-recursive(-N) # Do not recurse into sub-projects + --projects # Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path + ...args +] \ No newline at end of file From 1a4c6e9a6c62f479d315a7c904aa1d4e16e38821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Wed, 17 Apr 2024 19:13:23 +0300 Subject: [PATCH 08/75] Revert "fix: prefix conda commands with `conda`" (#820) Reverts nushell/nu_scripts#816 Fixes https://github.com/nushell/nu_scripts/issues/818 --- modules/virtual_environments/conda.nu | 4 ++-- modules/virtual_environments/nu_conda/nu_conda.nu | 6 +++--- modules/virtual_environments/nu_conda_2/conda.nu | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/virtual_environments/conda.nu b/modules/virtual_environments/conda.nu index 270be37a..70fd4f53 100644 --- a/modules/virtual_environments/conda.nu +++ b/modules/virtual_environments/conda.nu @@ -1,5 +1,5 @@ # Activate conda environment -export def --env "conda activate" [ +export def --env activate [ env_name?: string@'nu-complete conda envs' # name of the environment ] { let conda_info = (conda info --envs --json | from json) @@ -73,7 +73,7 @@ export def --env "conda activate" [ } # Deactivate currently active conda environment -export def --env "conda deactivate" [] { +export def --env deactivate [] { let path_name = if "PATH" in $env { "PATH" } else { "Path" } $env.$path_name = $env.CONDA_OLD_PATH diff --git a/modules/virtual_environments/nu_conda/nu_conda.nu b/modules/virtual_environments/nu_conda/nu_conda.nu index 4383c043..89a9b4d0 100644 --- a/modules/virtual_environments/nu_conda/nu_conda.nu +++ b/modules/virtual_environments/nu_conda/nu_conda.nu @@ -22,7 +22,7 @@ export-env { $env.CONDA_CURR = null } -export def --env "conda activate" [name: string] { +export def --env activate [name: string] { if ($env.CONDA_ROOT | is-empty) { print "Neither Conda nor Mamba is valid." return @@ -44,7 +44,7 @@ export def --env "conda activate" [name: string] { load-env ({CONDA_CURR: $name} | merge $new_path) } -export def --env "conda deactivate" [] { +export def --env deactivate [] { if ($env.CONDA_ROOT | is-empty) { print "Neither Conda nor Mamba is valid." return @@ -55,7 +55,7 @@ export def --env "conda deactivate" [] { load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH} } -export def --env "conda list" [] { +export def --env list [] { $env.CONDA_ENVS | flatten | transpose | diff --git a/modules/virtual_environments/nu_conda_2/conda.nu b/modules/virtual_environments/nu_conda_2/conda.nu index cd206a30..ccbd3e06 100644 --- a/modules/virtual_environments/nu_conda_2/conda.nu +++ b/modules/virtual_environments/nu_conda_2/conda.nu @@ -21,7 +21,7 @@ def --env load-conda-info-env [] { } # Activate conda environment -export def --env "conda activate" [ +export def --env activate [ env_name: string@'nu-complete conda envs' = "base" # name of the environment ] { load-conda-info-env @@ -94,7 +94,7 @@ export def --env "conda activate" [ } # Deactivate currently active conda environment -export def --env "conda deactivate" [] { +export def --env deactivate [] { let path_name = if "PATH" in $env { "PATH" } else { "Path" } $env.$path_name = $env.CONDA_OLD_PATH From b95f260bb41b5950dbd1c9519261081f206124b2 Mon Sep 17 00:00:00 2001 From: nils-degroot <53556985+nils-degroot@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:28:15 +0200 Subject: [PATCH 09/75] Add `zellij action new-tab` completions (#821) This PR add completions for this `zellij action new-tab` command, which is currently missing. --- .../zellij/zellij-completions.nu | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/custom-completions/zellij/zellij-completions.nu b/custom-completions/zellij/zellij-completions.nu index 14d369b3..68291ada 100644 --- a/custom-completions/zellij/zellij-completions.nu +++ b/custom-completions/zellij/zellij-completions.nu @@ -81,6 +81,23 @@ def "nu-complete sessions" [] { ^zellij ls -n | lines | parse "{value} {description}" } +def "nu-complete zellij layouts" [] { + let layout_dir = if 'ZELLIJ_CONFIG_DIR' in $env { + [$env.ZELLIJ_CONFIG_DIR "layouts"] | path join + } else { + match $nu.os-info.name { + "linux" => "~/.config/zellij/layouts/" + "mac" => "~/Library/Application Support/org.Zellij-Contributors.Zellij/layouts" + _ => (error make { msg: "Unsupported OS for zellij" }) + } + } + + ls ( $layout_dir | path expand ) + | where name =~ "\\.kdl" + | get name + | each { |$it| { value: ($it | path basename | str replace ".kdl" ""), description: $it } } +} + # Turned off since it messes with sub-commands #export extern "zellij" [ # command?: string@"nu-complete zellij" @@ -106,6 +123,15 @@ export extern "zellij action rename-tab" [ name: string # Name for the tab ] +# Create a new tab, optionally with a specified tab layout and name +export extern "zellij action new-tab" [ + --cwd(-c): path # Change the working directory of the new tab + --help(-h) # Print help information + --layout(-l): string@"nu-complete zellij layouts" # Layout ot use for the new tab + --layout-dir: path # Default folder to look for layouts + --name(-n): string # Name for the tab +] + # Attach to a session export extern "zellij attach" [ session_name: string@"nu-complete sessions" # Name of the session to attach to From dfdd5692d78e05e1a8fd69fdf75557c11342303a Mon Sep 17 00:00:00 2001 From: Devyn Cairns Date: Fri, 19 Apr 2024 13:43:09 -0700 Subject: [PATCH 10/75] Add nu_plugin_nu_example to bump-version.nu (#822) What it says on the tin. This just updates the `bump-version.nu` script to also edit the version in the new nu_plugin_nu_example plugin, the same way it does for python --- make_release/bump-version.nu | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/make_release/bump-version.nu b/make_release/bump-version.nu index 6b5d4df5..1ea42c67 100755 --- a/make_release/bump-version.nu +++ b/make_release/bump-version.nu @@ -36,7 +36,10 @@ def main [ | save --force $file } - ["crates/nu_plugin_python/nu_plugin_python_example.py"] | each {|file| + [ + "crates/nu_plugin_python/nu_plugin_python_example.py" + "crates/nu_plugin_nu_example/nu_plugin_nu_example.nu" + ] | each {|file| log debug $"bumping ($file) from ($version) to ($new_version)" open --raw $file | str replace --all $'NUSHELL_VERSION = "($version)"' $'NUSHELL_VERSION = "($new_version)"' From 912bea4588ba089aebe956349488e7f78e56061c Mon Sep 17 00:00:00 2001 From: Konstantins Zmanovskis Date: Tue, 23 Apr 2024 13:35:10 +0200 Subject: [PATCH 11/75] Winget custom completions fixes (#823) Here is a bunch of fixes I implemented to make Winget custom completion script functional. Namely, - Made it compatible with the latest Nushell version - Fixed parsing of Winget show command - Added the missing command aliases - Implemented a workaround for the in Winget itself when filtering for a particular package source - https://github.com/microsoft/winget-cli/issues/4236 --- .../winget/winget-completions.nu | 209 +++++++++++------- 1 file changed, 132 insertions(+), 77 deletions(-) diff --git a/custom-completions/winget/winget-completions.nu b/custom-completions/winget/winget-completions.nu index 7db72673..9795e4c7 100644 --- a/custom-completions/winget/winget-completions.nu +++ b/custom-completions/winget/winget-completions.nu @@ -28,11 +28,11 @@ def "nu-complete winget source type" [] { def "nu-complete winget flagify" [name: string, value: any, --short(-s)] { let flag_start = if $short { '-' } else { '--' } if $value == null or $value == false { - "" + [] } else if $value == true { - $"($flag_start)($name)" + [$"($flag_start)($name)"] } else { - $"($flag_start)($name) ($value)" + [$"($flag_start)($name)", $"($value)"] } } @@ -55,7 +55,7 @@ def "nu-complete winget install name" [] { } else { # Chinese characters break parsing, filter broken entries with `where source == winget` let data = (winget search | where source == winget | select name id) - $data | save $path | ignore + $data | save --force $path | ignore $data | get name | each { |it| $"(char dq)($it)(char dq)" } | str replace "…" "" } { @@ -75,21 +75,23 @@ def "nu-complete winget install id" [] { } else { # Chinese characters break parsing, filter broken entries with `where source == winget` let data = (winget search | where source == winget | select name id) - $data | save $path | ignore + $data | save --force $path | ignore $data | get id | str replace "…" "" } } def "nu-complete winget parse table" [lines: any] { let header = ( - $lines | first - | parse -r '(?PName\s+)(?PId\s+)(?PVersion\s+)?(?PAvailable\s+)?(?PSource\s*)?' + $lines + | first + | parse -r '(?PName\s+)(?PId\s+)(?PVersion\s+)?(?PMatch\s+)?(?PAvailable\s+)?(?PSource\s*)?' | first ) let lengths = { name: ($header.name | str length), id: ($header.id | str length), version: ($header.version | str length), + match: ($header.match | str length), available: ($header.available | str length), source: ($header.source | str length) } @@ -103,16 +105,23 @@ def "nu-complete winget parse table" [lines: any] { ) } else { "" } - let available = if $lengths.available > 0 { + let match = if $lengths.match > 0 { ( $it | skip ($lengths.name + $lengths.id + $lengths.version) + | first $lengths.match | str join | str trim + ) + } else { "" } + + let available = if $lengths.available > 0 { + ( + $it | skip ($lengths.name + $lengths.id + $lengths.version + $lengths.match) | first $lengths.available | str join | str trim ) } else { "" } let source = if $lengths.source > 0 { ( - $it | skip ($lengths.name + $lengths.id + $lengths.version + $lengths.available) + $it | skip ($lengths.name + $lengths.id + $lengths.version + $lengths.match + $lengths.available) | str join | str trim ) } else { "" } @@ -121,6 +130,7 @@ def "nu-complete winget parse table" [lines: any] { name: ($it | first $lengths.name | str join | str trim), id: ($it | skip $lengths.name | first $lengths.id | str join | str trim), version: $version, + match: $match, available: $available, source: $source } @@ -157,8 +167,9 @@ export extern "winget install" [ --accept_source_agreements, # Accept all source agreements during source operations --help(-?) # Display the help for this command ] +export alias "winget add" = winget install -def "winget show" [ +export def "winget show" [ pos_query?: string, --query(-q): string, # The query used to search for a package --id: string, # Filter results by id @@ -183,9 +194,22 @@ def "winget show" [ ] { let flagify = { |name, value| nu-complete winget flagify $name $value } - let command = ([ - "winget show" - $pos_query, + def sanitize-line []: string -> string { + let it = $in + let parsed = ($it | parse '{name}:{value}') + if ($parsed | is-empty) { return $"($it)" } + let parsed = ($parsed | first) + try { + $"($parsed.name):(if ($parsed.value | str trim | is-empty) { '' } else { $"(char space)(char dq)($parsed.value | str trim)(char dq)" })" + } catch { + $"($it)" + } + } + + let params = ([ + "show" + ] | append ([ + $pos_query (do $flagify query $query) (do $flagify id $id) (do $flagify name $name) @@ -205,24 +229,27 @@ def "winget show" [ (do $flagify header $header) (do $flagify accept_source_agreements $accept_source_agreements) (do $flagify help $help) - ] | str join ' ') + ] | flatten) | filter { not ($in | is-empty)}) - if $raw or $help { - ^$command + let output = ^winget ...$params + if $raw or $help or ($output | str contains "No package selection argument was provided") { + $output } else { - let output = (^$command | lines) - if ($output | first) =~ "Multiple packages found matching input criteria." { - $"(ansi yellow)($output | first | str trim)(ansi reset)" - nu-complete winget parse table ($output | skip 1) | select name id source - } else if ($output | first) =~ "No package found matching input criteria." { - $"(ansi yellow)($output | first | str trim)(ansi reset)" + let lines = ($output | lines) + + if ($lines | first) =~ "Multiple packages found matching input criteria." { + $"(ansi yellow)($lines | first | str trim)(ansi reset)" + nu-complete winget parse table ($lines | skip 1) | select name id source + } else if ($lines | first) =~ "No package found matching input criteria." { + $"(ansi yellow)($lines | first | str trim)(ansi reset)" } else { - let header = ($output | first | parse -r 'Found (?P.+) \[(?P.+)\]') - let manifest = ($output | skip 1 | str join (char newline) | from yaml) - $header | first | merge {|| $manifest } + let header = ($lines | first | parse -r 'Found (?P.+) \[(?P.+)\]') + let manifest = ($lines | skip | each { sanitize-line } | str join (char newline) | from yaml) + $header | first | merge $manifest } } } +export alias "winget view" = winget show # Manage sources of packages export extern "winget source" [ @@ -240,25 +267,25 @@ export extern "winget source add" [ ] # List current sources -def "winget source list" [ +export def "winget source list" [ pos_name?: string, # Name of the source --name(-n): string, # Name of the source --raw, # Output the raw CLI output instead of structured data --help(-?) # Display the help for this command ] { let flagify = { |name, value| nu-complete winget flagify $name $value } - - let command = ([ - "winget source list" + let params = ([ + "source" + "list" $pos_name (do $flagify name $name) (do $flagify help $help) - ] | str join ' ') + ] | compact --empty) if $raw or $help { - ^$command + ^winget ...$params } else { - let output = (^$command | lines) + let output = (^winget ...$params | lines) if ($output | length) == 1 { $"(ansi light_red)($output | first)(ansi reset)" } else { @@ -266,18 +293,21 @@ def "winget source list" [ } } } +export alias "winget source ls" = winget source list # Update current sources export extern "winget source update" [ --name(-n): string, # Name of the source --help(-?) # Display the help for this command ] +export alias "winget source refresh" = winet source update # Remove current sources export extern "winget source remove" [ --name(-n): string, # Name of the source --help(-?) # Display the help for this command ] +export alias "winget source rm" = winget source remove # Reset sources export extern "winget source reset" [ @@ -293,7 +323,7 @@ export extern "winget source export" [ ] # Find and show basic info of packages -def "winget search" [ +export def "winget search" [ pos_query?: string, --query(-q): string, # The query used to search for a package --id: string, # Filter results by id @@ -311,37 +341,45 @@ def "winget search" [ ] { let flagify = { |name, value| nu-complete winget flagify $name $value } - let command = ([ - "winget search" - $pos_query - (do $flagify query $query) - (do $flagify id $id) - (do $flagify name $name) - (do $flagify moniker $moniker) - (do $flagify tag $tag) - (do $flagify command $command) - (do $flagify source $source) - (do $flagify count $count) - (do $flagify exact $exact) - (do $flagify header $header) - (do $flagify accept_source_agreements $accept_source_agreements) - (do $flagify help $help) - ] | str join ' ') - + let params = [ + "search" + $"($pos_query)" + ] + | append ( + [ + (do $flagify query $query) + (do $flagify id $id) + (do $flagify name $name) + (do $flagify moniker $moniker) + (do $flagify tag $tag) + (do $flagify command $command) + (do $flagify source $source) + (do $flagify count $count) + (do $flagify exact $exact) + (do $flagify header $header) + (do $flagify accept_source_agreements $accept_source_agreements) + (do $flagify help $help) + ] + | flatten + | where { not ($in | is-empty) } + ) + + let output = (^winget ...$params) if $raw or $help { - ^$command + $output } else { - let output = (^$command | lines) - if ($output | length) == 1 { - $"(ansi light_red)($output | first)(ansi reset)" + let lines = ($output | lines) + if ($lines | length) == 1 { + $"(ansi light_red)($lines | first)(ansi reset)" } else { - nu-complete winget parse table $output | select name id version source + nu-complete winget parse table $lines | select name id version source } } } +export alias "winget find" = winget search # Display installed packages in a structured way. -def "winget list" [ +export def "winget list" [ pos_query?: string, --query(-q): string, # The query used to search for a package --id: string, # Filter results by id @@ -359,34 +397,48 @@ def "winget list" [ ] { let flagify = { |name, value| nu-complete winget flagify $name $value } - let command = ([ - "winget list" - $pos_query, - (do $flagify query $query) - (do $flagify id $id) - (do $flagify name $name) - (do $flagify moniker $moniker) - (do $flagify tag $tag) - (do $flagify command $command) - (do $flagify source $source) - (do $flagify count $count) - (do $flagify exact $exact) - (do $flagify header $header) - (do $flagify accept_source_agreements $accept_source_agreements) - (do $flagify help $help) - ] | str join ' ') + let params = ( + [ + "list" + ] + | append ( + [ + $"($pos_query)" + (do $flagify query $query) + (do $flagify id $id) + (do $flagify name $name) + (do $flagify moniker $moniker) + (do $flagify tag $tag) + (do $flagify command $command) + # (do $flagify source $source) # see comment below + (do $flagify count $count) + (do $flagify exact $exact) + (do $flagify header $header) + (do $flagify accept_source_agreements $accept_source_agreements) + (do $flagify help $help) + ] + | flatten + | filter { not ($in | is-empty) }) + ) + let output = ^winget ...$params if $help or $raw { - ^$command + $output } else { - let output = (^$command | lines) - if ($output | length) == 1 { - $"(ansi light_red)($output | first)(ansi reset)" + let lines = ($output | lines) + if ($lines | length) == 1 { + $"(ansi light_red)($lines | first)(ansi reset)" } else { - nu-complete winget parse table $output + let truncated = $lines | last | $in == "" + nu-complete winget parse table (if $truncated { $lines | drop } else { $lines }) + | reject match + # Because of a bug: https://github.com/microsoft/winget-cli/issues/4236 + # we need to filter it with the "where" command + | if ($source | is-not-empty) { $in | where source == $source } else { $in } } } } +export alias "winget ls" = winget list # Upgrades the given package export extern "winget upgrade" [ @@ -411,6 +463,7 @@ export extern "winget upgrade" [ --all, # Update all installed packages to latest if available --help(-?) # Display the help for this command ] +export alias "winget update" = winget upgrade # Uninstalls the given package export extern "winget uninstall" [ @@ -428,6 +481,8 @@ export extern "winget uninstall" [ --log(-o): path, # Log location (if supported) --help(-?) # Display the help for this command ] +export alias "winget remove" = winget uninstall +export alias "winget rm" = winget uninstall # Helper to hash installer files export extern "winget hash" [ From 8c9d0e13bf1765940bcacb775df66cc119390534 Mon Sep 17 00:00:00 2001 From: zhangym <40376181+zhangymPerson@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:44:17 +0800 Subject: [PATCH 12/75] feat: add git worktree command (#824) --- custom-completions/git/git-completions.nu | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/custom-completions/git/git-completions.nu b/custom-completions/git/git-completions.nu index 3d3850c3..d5bd103c 100644 --- a/custom-completions/git/git-completions.nu +++ b/custom-completions/git/git-completions.nu @@ -491,3 +491,70 @@ export extern "git bisect reset" [ export extern "git help" [ command: string@"nu-complete git subcommands" # subcommand to show help for ] + +# git worktree +export extern "git worktree" [ + --help(-h) # display the help message for this command + ...args +] + +# create a new working tree +export extern "git worktree add" [ + --help(-h) # display the help message for this command + --force(-f) # checkout even if already checked out in other worktree + -b # create a new branch + -B # create or reset a branch + --detach(-d) # detach HEAD at named commit + --checkout # populate the new working tree + --lock # keep the new working tree locked + --reason # reason for locking + --quiet(-q) # suppress progress reporting + --track # set up tracking mode (see git-branch(1)) + --guess-remote # try to match the new branch name with a remote-tracking branch + ...args +] + +# list details of each worktree +export extern "git worktree list" [ + --help(-h) # display the help message for this command + --porcelain # machine-readable output + --verbose(-v) # show extended annotations and reasons, if available + --expire # add 'prunable' annotation to worktrees older than