70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
package cmd
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
"github.com/Jaculabilis/intake/core"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var infoCmd = &cobra.Command{
|
|
Use: "info",
|
|
Short: "Print intake config",
|
|
Long: `Print intake config as it would be used by other commands.
|
|
`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
info()
|
|
},
|
|
DisableFlagsInUseLine: true,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(infoCmd)
|
|
}
|
|
|
|
func info() {
|
|
fmt.Printf("Revision: %s\n", core.GetRevInfo())
|
|
|
|
fmt.Printf("Data path: %s\n", dataPath)
|
|
fmt.Printf("Database: %s\n", core.DatabasePath(dataPath))
|
|
|
|
db := openDb()
|
|
|
|
row := db.QueryRow("select exists(select 1 from password)")
|
|
var hasPassword bool
|
|
if err := row.Scan(&hasPassword); err != nil && err != sql.ErrNoRows {
|
|
fmt.Printf("Password: error: %v\n", err)
|
|
} else {
|
|
if hasPassword {
|
|
fmt.Printf("Password: yes\n")
|
|
} else {
|
|
fmt.Printf("Password: no\n")
|
|
}
|
|
}
|
|
|
|
row = db.QueryRow("select count(*) from sources")
|
|
var sources int
|
|
if err := row.Scan(&sources); err != nil {
|
|
fmt.Printf("Sources: error: %v\n", err)
|
|
} else {
|
|
fmt.Printf("Sources: %d\n", sources)
|
|
}
|
|
|
|
row = db.QueryRow("select count(*) from channels")
|
|
var channels int
|
|
if err := row.Scan(&channels); err != nil {
|
|
fmt.Printf("Channels: error: %v\n", err)
|
|
} else {
|
|
fmt.Printf("Channels: %d\n", channels)
|
|
}
|
|
|
|
row = db.QueryRow("select count(*) from items")
|
|
var items int
|
|
if err := row.Scan(&items); err != nil {
|
|
fmt.Printf("Items: error: %v\n", err)
|
|
} else {
|
|
fmt.Printf("Items: %d\n", items)
|
|
}
|
|
}
|