mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
feat(cli): restore --version
option
This commit is contained in:
parent
3e06366efa
commit
a0002e16b5
|
@ -1,17 +1,23 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/jandedobbeleer/oh-my-posh/src/build"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
configFlag string
|
configFlag string
|
||||||
shellName string
|
shellName string
|
||||||
silent bool
|
printVersion bool
|
||||||
// Deprecated flags, should be kept to avoid breaking CLI integration.
|
|
||||||
|
// for internal use only
|
||||||
|
silent bool
|
||||||
|
|
||||||
|
// deprecated
|
||||||
initialize bool
|
initialize bool
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +33,10 @@ on getting started, have a look at the docs at https://ohmyposh.dev`,
|
||||||
runInit(strings.ToLower(shellName))
|
runInit(strings.ToLower(shellName))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if printVersion {
|
||||||
|
fmt.Println(build.Version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_ = cmd.Help()
|
_ = cmd.Help()
|
||||||
},
|
},
|
||||||
|
@ -42,6 +52,7 @@ func Execute() {
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.PersistentFlags().StringVarP(&configFlag, "config", "c", "", "config file path")
|
RootCmd.PersistentFlags().StringVarP(&configFlag, "config", "c", "", "config file path")
|
||||||
RootCmd.PersistentFlags().BoolVar(&silent, "silent", false, "do not print anything")
|
RootCmd.PersistentFlags().BoolVar(&silent, "silent", false, "do not print anything")
|
||||||
|
RootCmd.Flags().BoolVar(&printVersion, "version", false, "print the version number and exit")
|
||||||
|
|
||||||
// Deprecated flags, should be kept to avoid breaking CLI integration.
|
// Deprecated flags, should be kept to avoid breaking CLI integration.
|
||||||
RootCmd.Flags().BoolVarP(&initialize, "init", "i", false, "init")
|
RootCmd.Flags().BoolVarP(&initialize, "init", "i", false, "init")
|
||||||
|
|
Loading…
Reference in a new issue