mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-20 07:02:37 +00:00
feat: add initial implementation of a traefik like cli
This commit is contained in:
@@ -1,42 +1,23 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"tinyauth/internal/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/traefik/paerser/cli"
|
||||
)
|
||||
|
||||
type versionCmd struct {
|
||||
root *cobra.Command
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newVersionCmd(root *cobra.Command) *versionCmd {
|
||||
return &versionCmd{
|
||||
root: root,
|
||||
func versionCmd() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Description: "Print the version number of Tinyauth.",
|
||||
Configuration: nil,
|
||||
Resources: nil,
|
||||
Run: func(_ []string) error {
|
||||
fmt.Printf("Version: %s\n", config.Version)
|
||||
fmt.Printf("Commit Hash: %s\n", config.CommitHash)
|
||||
fmt.Printf("Build Timestamp: %s\n", config.BuildTimestamp)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *versionCmd) Register() {
|
||||
c.cmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version number of Tinyauth",
|
||||
Long: `All software has versions. This is Tinyauth's.`,
|
||||
Run: c.run,
|
||||
}
|
||||
|
||||
if c.root != nil {
|
||||
c.root.AddCommand(c.cmd)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *versionCmd) GetCmd() *cobra.Command {
|
||||
return c.cmd
|
||||
}
|
||||
|
||||
func (c *versionCmd) run(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Version: %s\n", config.Version)
|
||||
fmt.Printf("Commit Hash: %s\n", config.CommitHash)
|
||||
fmt.Printf("Build Timestamp: %s\n", config.BuildTimestamp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user