Last active
January 24, 2026 05:46
-
-
Save hymkor/f28a0aaf6f85947a6fbcba9454e764ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $argv = $args | |
| $saveEncode = $null | |
| if ([Console]::IsOutputRedirected) { | |
| $saveEncode = [System.Console]::OutputEncoding | |
| [System.Console]::OutputEncoding=[System.Text.Encoding]::UTF8 | |
| } | |
| Get-Content "go.mod" | | |
| Where-Object { $_ -like "module*" } | | |
| Select-Object -first 1 | | |
| ForEach-Object { | |
| $module = $_.SubString(7) | |
| $giturl = $module -replace "/v[1-9]$","" | |
| $parts = $giturl -split "/" | |
| $user = $parts[1] | |
| $repo = $parts[2] | |
| if ( (Test-Path "cmd\$repo") ){ | |
| $cmddir = "/cmd/$repo" | |
| } else { | |
| $cmddir = "" | |
| } | |
| if ( $argv.length -ge 1 ){ | |
| Write-Output @" | |
| ### [eget] インストーラーを使う場合 (クロスプラットフォーム) | |
| ``````sh | |
| brew install eget # Unix-like systems | |
| # or | |
| scoop install eget # Windows | |
| cd (YOUR-BIN-DIRECTORY) | |
| eget $user/$repo | |
| `````` | |
| [eget]: https://github.com/zyedidia/eget | |
| ### [scoop] インストーラーを使う場合 (Windowsのみ) | |
| `````` | |
| scoop install https://raw.githubusercontent.com/$user/$repo/master/$repo.json | |
| `````` | |
| もしくは | |
| `````` | |
| scoop bucket add hymkor https://github.com/hymkor/scoop-bucket | |
| scoop install $repo | |
| `````` | |
| [scoop]: https://scoop.sh/ | |
| ### "go install" を使う場合 (要Go言語開発環境) | |
| `````` | |
| go install $module$cmddir@latest | |
| `````` | |
| ``go install`` は ```$HOME/go/bin`` もしくは ```$GOPATH/bin`` へ実行ファイルを導入するので、``$repo`` を実行するにはそのディレクトリを ```$PATH`` に追加する必要があります。 | |
| "@ | |
| } else { | |
| Write-Output @" | |
| ### Use [eget] installer (cross-platform) | |
| ``````sh | |
| brew install eget # Unix-like systems | |
| # or | |
| scoop install eget # Windows | |
| cd (YOUR-BIN-DIRECTORY) | |
| eget $user/$repo | |
| `````` | |
| [eget]: https://github.com/zyedidia/eget | |
| ### Use [scoop]-installer (Windows only) | |
| `````` | |
| scoop install https://raw.githubusercontent.com/$user/$repo/master/$repo.json | |
| `````` | |
| or | |
| `````` | |
| scoop bucket add hymkor https://github.com/hymkor/scoop-bucket | |
| scoop install $repo | |
| `````` | |
| [scoop]: https://scoop.sh/ | |
| ### Use "go install" (requires Go toolchain) | |
| `````` | |
| go install $module$cmddir@latest | |
| `````` | |
| Because ``go install`` introduces the executable into ```$HOME/go/bin`` or ```$GOPATH/bin``, you need to add this directory to your ```$PATH`` to execute ``$repo``. | |
| "@ | |
| } | |
| } | |
| if ( $saveEncode -ne $null ){ | |
| [System.Console]::OutputEncoding=$saveEncode | |
| } | |
| # gist https://gist.github.com/hymkor/f28a0aaf6f85947a6fbcba9454e764ed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment