github.com/charypar/monobuild@v0.0.0-20211122220434-fd884ed50212/cmd/root.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/spf13/cobra" 8 ) 9 10 var rootCmd = &cobra.Command{ 11 Use: "monobuild", 12 Short: "A build orchestration tool for Continuous Integration in a monorepo.", 13 Long: `Read a graph of dependencies in a monorepo codebase (where separate 14 components live side by side) and decide what should be built, given the git 15 history.`, 16 } 17 18 type commonOptions struct { 19 dependencyFilesGlob string 20 repoManifestFile string 21 scope string 22 topLevel bool 23 printDependencies bool 24 dotFormat bool 25 printFull bool 26 } 27 28 var commonOpts commonOptions 29 30 func init() { 31 rootCmd.PersistentFlags().StringVar(&commonOpts.dependencyFilesGlob, "dependency-files", "**/Dependencies", "Search pattern for dependency files") 32 rootCmd.PersistentFlags().StringVarP(&commonOpts.repoManifestFile, "file", "f", "", "Full manifest file (as produced by 'print --full')") 33 rootCmd.PersistentFlags().StringVar(&commonOpts.scope, "scope", "", "Scope output to a single component and its dependencies") 34 rootCmd.PersistentFlags().BoolVar(&commonOpts.topLevel, "top-level", false, "Only list top-level components that nothing depends on") 35 } 36 37 // Execute the CLI 38 func Execute() { 39 err := rootCmd.Execute() 40 if err != nil { 41 fmt.Println(err) 42 os.Exit(1) 43 } 44 }