initial project structure

This commit is contained in:
Alex Goodman
2020-05-12 10:45:18 -04:00
parent fcddceb965
commit 1e5c7bb5c7
9 changed files with 861 additions and 5 deletions
+40
View File
@@ -0,0 +1,40 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"os"
)
const ApplicationName = "imgbom"
var rootOptions struct {
cfgFile string
}
var rootCmd = &cobra.Command{
Use: ApplicationName,
Short: "A container image BOM tool",
Long: `todo.`,
Run: doRunCmd,
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(loadApplicationConfig)
rootCmd.PersistentFlags().StringVar(&rootOptions.cfgFile, "config", "", "config file")
}
func loadApplicationConfig() {
// TODO...
}
func doRunCmd(cmd *cobra.Command, args []string) {
}
+33
View File
@@ -0,0 +1,33 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
type Version struct {
Version string
Commit string
BuildTime string
}
var version *Version
var versionCmd = &cobra.Command{
Use: "version",
Short: "show the version",
Run: printVersion,
}
func init() {
rootCmd.AddCommand(versionCmd)
}
func SetVersion(v *Version) {
version = v
}
func printVersion(cmd *cobra.Command, args []string) {
fmt.Printf("%s %s\n", ApplicationName, version.Version)
}