You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
// Copyright 2019 The Xorm Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
// Version means the version of reverse
|
|
Version = "0.1+dev"
|
|
|
|
reverseFile string
|
|
versionFlag *bool
|
|
|
|
rootCmd = &cobra.Command{
|
|
Version: Version,
|
|
Use: "reverse",
|
|
Short: "Reverse is a database reverse command line tool",
|
|
Long: `A flexsible and powerful command line tool to generate codes/docs from databases(SQLITE/Mysql/Postgres/MSSQL)`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if versionFlag != nil && *versionFlag {
|
|
fmt.Printf("Reverse %s\n", Version)
|
|
return
|
|
}
|
|
if reverseFile == "" {
|
|
fmt.Println("Need reverse file")
|
|
return
|
|
}
|
|
|
|
err := reverseFromConfig(reverseFile)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
},
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
versionFlag = rootCmd.Flags().BoolP("version", "v", false, "version of the tool")
|
|
rootCmd.Flags().StringVarP(&reverseFile, "file", "f", "", "yml file to apply for reverse")
|
|
}
|
|
|
|
// Execute represnets execute command
|
|
func Execute() error {
|
|
return rootCmd.Execute()
|
|
}
|