forked from mirrors/gomod2nix
Add generate subcommand
Which does the same as the previous root command.
This commit is contained in:
parent
52125f6072
commit
2792ae6af4
1 changed files with 13 additions and 2 deletions
15
cmd/root.go
15
cmd/root.go
|
@ -22,7 +22,16 @@ var rootCmd = &cobra.Command{
|
|||
Short: "Convert applications using Go modules -> Nix",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
return generateCmd(flagDirectory, flagOutDir, flagMaxJobs)
|
||||
return generateInternal(flagDirectory, flagOutDir, flagMaxJobs)
|
||||
},
|
||||
}
|
||||
|
||||
var generateCmd = &cobra.Command{
|
||||
Use: "generate",
|
||||
Short: "Run gomod2nix.toml generator",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
return generateInternal(flagDirectory, flagOutDir, flagMaxJobs)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -30,6 +39,8 @@ func init() {
|
|||
rootCmd.PersistentFlags().StringVar(&flagDirectory, "dir", "", "Go project directory")
|
||||
rootCmd.PersistentFlags().StringVar(&flagOutDir, "outdir", "", "Output directory (defaults to project directory)")
|
||||
rootCmd.PersistentFlags().IntVar(&flagMaxJobs, "jobs", 10, "Max number of concurrent jobs")
|
||||
|
||||
rootCmd.AddCommand(generateCmd)
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
@ -39,7 +50,7 @@ func Execute() {
|
|||
}
|
||||
}
|
||||
|
||||
func generateCmd(directory string, outDir string, maxJobs int) error {
|
||||
func generateInternal(directory string, outDir string, maxJobs int) error {
|
||||
if outDir == "" {
|
||||
outDir = directory
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue