mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
parent
3b1823682d
commit
c901575413
34
src/cli/notice.go
Normal file
34
src/cli/notice.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/platform"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/upgrade"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// noticeCmd represents the get command
|
||||
var noticeCmd = &cobra.Command{
|
||||
Use: "notice",
|
||||
Short: "Print the upgrade notice when a new version is available.",
|
||||
Long: "Print the upgrade notice when a new version is available.",
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
env := &platform.Shell{
|
||||
CmdFlags: &platform.Flags{
|
||||
Version: cliVersion,
|
||||
},
|
||||
}
|
||||
env.Init()
|
||||
defer env.Close()
|
||||
|
||||
if notice, hasNotice := upgrade.Notice(env); hasNotice {
|
||||
fmt.Println(notice)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() { //nolint:gochecknoinits
|
||||
RootCmd.AddCommand(noticeCmd)
|
||||
}
|
|
@ -210,7 +210,12 @@ func PrintInit(env platform.Environment) string {
|
|||
|
||||
shell := env.Flags().Shell
|
||||
configFile := env.Flags().Config
|
||||
var script string
|
||||
|
||||
var (
|
||||
script, notice string
|
||||
hasNotice bool
|
||||
)
|
||||
|
||||
switch shell {
|
||||
case PWSH, PWSH5:
|
||||
executable = quotePwshStr(executable)
|
||||
|
@ -251,7 +256,13 @@ func PrintInit(env platform.Environment) string {
|
|||
default:
|
||||
return fmt.Sprintf("echo \"No initialization script available for %s\"", shell)
|
||||
}
|
||||
notice, hasNotice := upgrade.Notice(env)
|
||||
|
||||
// only run this for shells that support
|
||||
// injecting the notice directly
|
||||
if shell != PWSH && shell != PWSH5 {
|
||||
notice, hasNotice = upgrade.Notice(env)
|
||||
}
|
||||
|
||||
return strings.NewReplacer(
|
||||
"::OMP::", executable,
|
||||
"::CONFIG::", configFile,
|
||||
|
|
|
@ -30,11 +30,6 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$env:POSH_THEME = (Resolve-Path -Path ::CONFIG::).ProviderPath
|
||||
}
|
||||
|
||||
# print upgrade notice
|
||||
if ("::UPGRADE::" -eq "true") {
|
||||
Write-Host "::UPGRADENOTICE::"
|
||||
}
|
||||
|
||||
# specific module support (disabled by default)
|
||||
if (($null -eq $env:POSH_GIT_ENABLED) -or ($null -eq (Get-Module 'posh-git'))) {
|
||||
$env:POSH_GIT_ENABLED = $false
|
||||
|
@ -404,6 +399,11 @@ Example:
|
|||
}
|
||||
}
|
||||
|
||||
$notice = @(Start-Utf8Process $script:OMPExecutable @("notice"))
|
||||
if ($notice) {
|
||||
Write-Host $notice -NoNewline
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function @(
|
||||
"Set-PoshContext"
|
||||
"Enable-PoshTooltips"
|
||||
|
|
Loading…
Reference in a new issue