"git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "97f199569620537c3d0d8821c3e23d87c81d7bd8"
Commit 0f0cd265 authored by Michael Yang's avatar Michael Yang
Browse files

cmd: add server version

parent 0db4706e
...@@ -1037,8 +1037,25 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error { ...@@ -1037,8 +1037,25 @@ func checkServerHeartbeat(cmd *cobra.Command, _ []string) error {
return nil return nil
} }
func versionHandler(cmd *cobra.Command, _ []string) {
fmt.Printf("ollama version %s\n", version.Version)
client, err := api.ClientFromEnvironment()
if err != nil {
return
}
serverVersion, err := client.Version(cmd.Context())
if err != nil {
return
}
fmt.Printf("server version %s\n", serverVersion)
}
func NewCLI() *cobra.Command { func NewCLI() *cobra.Command {
log.SetFlags(log.LstdFlags | log.Lshortfile) log.SetFlags(log.LstdFlags | log.Lshortfile)
cobra.EnableCommandSorting = false
rootCmd := &cobra.Command{ rootCmd := &cobra.Command{
Use: "ollama", Use: "ollama",
...@@ -1049,9 +1066,17 @@ func NewCLI() *cobra.Command { ...@@ -1049,9 +1066,17 @@ func NewCLI() *cobra.Command {
DisableDefaultCmd: true, DisableDefaultCmd: true,
}, },
Version: version.Version, Version: version.Version,
Run: func(cmd *cobra.Command, args []string) {
if version, _ := cmd.Flags().GetBool("version"); version {
versionHandler(cmd, args)
return
}
cmd.Print(cmd.UsageString())
},
} }
cobra.EnableCommandSorting = false rootCmd.Flags().BoolP("version", "v", false, "Show version information")
createCmd := &cobra.Command{ createCmd := &cobra.Command{
Use: "create MODEL", Use: "create MODEL",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment