From c9edb78accc109d0fa42d449417815fc83db979d Mon Sep 17 00:00:00 2001 From: Steve Francia Date: Thu, 1 Jul 2021 17:45:46 -0400 Subject: [PATCH] Change generator default license to none It's questionable that a default license makes any sense from a legal perspective. If the tool created the license without the user choosing it, then it may not even be applicable. Best to let the user choose their license with intent. --- cobra/cmd/add_test.go | 1 + cobra/cmd/init_test.go | 1 + cobra/cmd/licenses.go | 8 ++++---- cobra/cmd/root.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cobra/cmd/add_test.go b/cobra/cmd/add_test.go index c9b185b..20bc34f 100644 --- a/cobra/cmd/add_test.go +++ b/cobra/cmd/add_test.go @@ -10,6 +10,7 @@ import ( func TestGoldenAddCmd(t *testing.T) { viper.Set("useViper", true) + viper.Set("license", "apache") command := &Command{ CmdName: "test", CmdParent: parentName, diff --git a/cobra/cmd/init_test.go b/cobra/cmd/init_test.go index e364f40..ea80250 100644 --- a/cobra/cmd/init_test.go +++ b/cobra/cmd/init_test.go @@ -61,6 +61,7 @@ func TestGoldenInitCmd(t *testing.T) { assertNoErr(t, initCmd.Flags().Set("pkg-name", tt.pkgName)) viper.Set("useViper", true) + viper.Set("license", "apache") projectPath, err := initializeProject(tt.args) defer func() { if projectPath != "" { diff --git a/cobra/cmd/licenses.go b/cobra/cmd/licenses.go index 2b3a424..30c7b24 100644 --- a/cobra/cmd/licenses.go +++ b/cobra/cmd/licenses.go @@ -1,4 +1,4 @@ -// Copyright © 2015 Steve Francia . +// Copyright © 2021 Steve Francia . // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ func init() { } // getLicense returns license specified by user in flag or in config. -// If user didn't specify the license, it returns Apache License 2.0. +// If user didn't specify the license, it returns none // // TODO: Inspect project for existing license func getLicense() License { @@ -73,8 +73,8 @@ func getLicense() License { return findLicense(viper.GetString("license")) } - // If user didn't set any license, use Apache 2.0 by default. - return Licenses["apache"] + // If user didn't set any license, use none by default + return Licenses["none"] } func copyrightLine() string { diff --git a/cobra/cmd/root.go b/cobra/cmd/root.go index ae961be..51bba2c 100644 --- a/cobra/cmd/root.go +++ b/cobra/cmd/root.go @@ -50,7 +50,7 @@ func init() { cobra.CheckErr(viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))) cobra.CheckErr(viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))) viper.SetDefault("author", "NAME HERE ") - viper.SetDefault("license", "apache") + viper.SetDefault("license", "none") rootCmd.AddCommand(addCmd) rootCmd.AddCommand(initCmd)