d5f8fac465857941eabfbd0fcb58610c0fc002dc

Author
Shaun Tabone <shauntab@gmail.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Feature/add dotnet plugin (#8503)

* Added dotnet CLI aliases and completions

* Modified README

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..7a6d6a995d0ad27a8abf903afc4c1162bf8eab62
  4--- /dev/null
  5+++ b/plugins/dotnet/README.md
  6@@ -0,0 +1,21 @@
  7+# .NET Core CLI plugin
  8+
  9+This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/).
 10+
 11+To use it, add `dotnet` to the plugins array in your zshrc file.
 12+
 13+```
 14+plugins=(... dotnet)
 15+```
 16+
 17+## Aliases
 18+
 19+| Alias | Command      | Description                                                       |
 20+|-------|--------------|-------------------------------------------------------------------|
 21+| dn    | dotnet new   | Create a new .NET project or file.                                |
 22+| dr    | dotnet run   | Build and run a .NET project output.                              |
 23+| dt    | dotnet test  | Run unit tests using the test runner specified in a .NET project. |
 24+| ds    | dotnet sln   | Modify Visual Studio solution files.                              |
 25+| da    | dotnet add   | Add a package or reference to a .NET project.                     |
 26+| dp    | dotnet pack  | Create a NuGet package.                                           |
 27+| dng   | dotnet nuget | Provides additional NuGet commands.                               |
 28diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh
 29new file mode 100644
 30index 0000000000000000000000000000000000000000..8b9a45a97cfd6221f491b755c48aac5da6b696e6
 31--- /dev/null
 32+++ b/plugins/dotnet/dotnet.plugin.zsh
 33@@ -0,0 +1,117 @@
 34+# --------------------------------------------------------------------- #
 35+# Aliases and Completions for .NET Core (https://dotnet.microsoft.com/) #
 36+# Author: Shaun Tabone (https://github.com/xontab)                      #
 37+# --------------------------------------------------------------------- #
 38+
 39+# Helper function to cache and load completions
 40+local cache_base_path="${ZSH_CACHE_DIR}/dotnet_"
 41+_dotnet_cache_completion() {
 42+    local cache="${cache_base_path}$(echo $1)_completion"
 43+    if [[ ! -f $cache ]]; then
 44+        $2 $cache
 45+    fi
 46+
 47+    [[ -f $cache ]] && cat $cache
 48+}
 49+
 50+_dotnet_cache_completion_cleanup() {
 51+    local cache="${cache_base_path}$(echo $1)_completion"
 52+    rm -f $cache
 53+}
 54+
 55+# --------------------------------------------------------------------- #
 56+# dotnet new                                                            #
 57+# ALIAS: dn                                                             #
 58+# --------------------------------------------------------------------- #
 59+_dotnet_new_completion() {
 60+    if [ $commands[dotnet] ]; then
 61+        dotnet new -l | tail -n +21 | sed 's/  \+/:/g' | cut -d : -f 2 >$1
 62+    fi
 63+}
 64+
 65+_dotnet_new_completion_cached() {
 66+    _dotnet_cache_completion 'new' _dotnet_new_completion
 67+}
 68+
 69+_dotnet_cache_completion_cleanup 'new'
 70+
 71+alias dn='dotnet new'
 72+
 73+# --------------------------------------------------------------------- #
 74+# dotnet                                                                #
 75+# --------------------------------------------------------------------- #
 76+_dotnet() {
 77+    if [ $CURRENT -eq 2 ]; then
 78+        _arguments \
 79+            '--diagnostics[Enable diagnostic output.]' \
 80+            '--help[Show command line help.]' \
 81+            '--info[Display .NET Core information.]' \
 82+            '--list-runtimes[Display the installed runtimes.]' \
 83+            '--list-sdks[Display the installed SDKs.]' \
 84+            '--version[Display .NET Core SDK version in use.]'
 85+
 86+        _values \
 87+            'add[Add a package or reference to a .NET project.]' \
 88+            'build[Build a .NET project.]' \
 89+            'build-server[Interact with servers started by a build.]' \
 90+            'clean[Clean build outputs of a .NET project.]' \
 91+            'help[Show command line help.]' \
 92+            'list[List project references of a .NET project.]' \
 93+            'msbuild[Run Microsoft Build Engine (MSBuild) commands.]' \
 94+            'new[Create a new .NET project or file.]' \
 95+            'nuget[Provides additional NuGet commands.]' \
 96+            'pack[Create a NuGet package.]' \
 97+            'publish[Publish a .NET project for deployment.]' \
 98+            'remove[Remove a package or reference from a .NET project.]' \
 99+            'restore[Restore dependencies specified in a .NET project.]' \
100+            'run[Build and run a .NET project output.]' \
101+            'sln[Modify Visual Studio solution files.]' \
102+            'store[Store the specified assemblies in the runtime package store.]' \
103+            'test[Run unit tests using the test runner specified in a .NET project.]' \
104+            'tool[Install or manage tools that extend the .NET experience.]' \
105+            'vstest[Run Microsoft Test Engine (VSTest) commands.]' \
106+            'dev-certs[Create and manage development certificates.]' \
107+            'fsi[Start F# Interactive / execute F# scripts.]' \
108+            'sql-cache[SQL Server cache command-line tools.]' \
109+            'user-secrets[Manage development user secrets.]' \
110+            'watch[Start a file watcher that runs a command when files change.]'
111+        return
112+    fi
113+
114+    if [ $CURRENT -eq 3 ]; then
115+        case ${words[2]} in
116+        "new")
117+            compadd -X ".NET Installed Templates" $(_dotnet_new_completion_cached)
118+            return
119+            ;;
120+        "sln")
121+            _values \
122+                'add[Add one or more projects to a solution file.]' \
123+                'list[List all projects in a solution file.]' \
124+                'remove[Remove one or more projects from a solution file.]'
125+            return
126+            ;;
127+        "nuget")
128+            _values \
129+                'delete[Deletes a package from the server.]' \
130+                'locals[Clears or lists local NuGet resources such as http requests cache, packages folder, plugin operations cache  or machine-wide global packages folder.]' \
131+                'push[Pushes a package to the server and publishes it.]'
132+            return