mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 14:36:33 +01:00
initial project structure
This commit is contained in:
+40
@@ -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) {
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user