mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Merge branch 'main' into cache-cmd
This commit is contained in:
commit
170df80621
23 changed files with 1118 additions and 356 deletions
|
|
@ -35,7 +35,7 @@ var crawlCmd = &cobra.Command{
|
|||
return nil
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
systems, err := crawler.CrawlBMC(crawler.CrawlerConfig{
|
||||
systems, err := crawler.CrawlBMCForSystems(crawler.CrawlerConfig{
|
||||
URI: args[0],
|
||||
Username: cmd.Flag("username").Value.String(),
|
||||
Password: cmd.Flag("password").Value.String(),
|
||||
|
|
|
|||
14
cmd/root.go
14
cmd/root.go
|
|
@ -74,13 +74,13 @@ func Execute() {
|
|||
func init() {
|
||||
currentUser, _ = user.Current()
|
||||
cobra.OnInitialize(InitializeConfig)
|
||||
rootCmd.PersistentFlags().IntVar(&concurrency, "concurrency", -1, "set the number of concurrent processes")
|
||||
rootCmd.PersistentFlags().IntVar(&timeout, "timeout", 5, "set the timeout")
|
||||
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "set the config file path")
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "set to enable/disable verbose output")
|
||||
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "set to enable/disable debug messages")
|
||||
rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "set the access token")
|
||||
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "set the scanning result cache path")
|
||||
rootCmd.PersistentFlags().IntVar(&concurrency, "concurrency", -1, "Set the number of concurrent processes")
|
||||
rootCmd.PersistentFlags().IntVar(&timeout, "timeout", 5, "Set the timeout for requests")
|
||||
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Set the config file path")
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Set to enable/disable verbose output")
|
||||
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Set to enable/disable debug messages")
|
||||
rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "Set the access token")
|
||||
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "Set the scanning result cache path")
|
||||
|
||||
// bind viper config flags with cobra
|
||||
checkBindFlagError(viper.BindPFlag("concurrency", rootCmd.PersistentFlags().Lookup("concurrency")))
|
||||
|
|
|
|||
|
|
@ -1,40 +1,18 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OpenCHAMI/magellan/internal/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
output string
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Use: "version",
|
||||
Short: "Print version info and exit",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if cmd.Flag("commit").Value.String() == "true" {
|
||||
output = commit
|
||||
if date != "" {
|
||||
output += " built @ " + date
|
||||
}
|
||||
fmt.Println(output)
|
||||
} else {
|
||||
fmt.Println(version)
|
||||
}
|
||||
version.PrintVersionInfo()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
versionCmd.Flags().Bool("commit", false, "show the version commit")
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
func SetVersionInfo(buildVersion string, buildCommit string, buildDate string) {
|
||||
version = buildVersion
|
||||
commit = buildCommit
|
||||
date = buildDate
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue