diff --git a/archived/licenses[WIP]/tools/gen-license-go/README.md b/archived/licenses[WIP]/tools/gen-license-go/README.md index dfbfcca8..3668c827 100644 --- a/archived/licenses[WIP]/tools/gen-license-go/README.md +++ b/archived/licenses[WIP]/tools/gen-license-go/README.md @@ -8,7 +8,7 @@ More importantly, the main purpose of this tool is to incorporate those aforesai a brand new license: 996.icu, defined by [996.icu](https://github.com/996icu/996.ICU). ## Usage -There are three executable files of different operating systems: macOS, Linux and Windows, located in `bin` directory, you can pick the specific bin file based on your OS, then put the `licenses` directory and `gen-license-go` file into the same path. +There are three executable files for different operating systems: macOS, Linux and Windows, located in `bin` directory, you can pick the specific bin file based on your OS, then put the `licenses` directory and `gen-license-go` file into the same path. ```sh # Get the help from this tool: ./gen-license-go -h diff --git a/archived/licenses[WIP]/tools/gen-license-go/bin/linux/gen-license-go b/archived/licenses[WIP]/tools/gen-license-go/bin/linux/gen-license-go index a98c4a7e..1de68047 100755 Binary files a/archived/licenses[WIP]/tools/gen-license-go/bin/linux/gen-license-go and b/archived/licenses[WIP]/tools/gen-license-go/bin/linux/gen-license-go differ diff --git a/archived/licenses[WIP]/tools/gen-license-go/bin/osx/gen-license-go b/archived/licenses[WIP]/tools/gen-license-go/bin/osx/gen-license-go index 37d1fae7..9041c32a 100755 Binary files a/archived/licenses[WIP]/tools/gen-license-go/bin/osx/gen-license-go and b/archived/licenses[WIP]/tools/gen-license-go/bin/osx/gen-license-go differ diff --git a/archived/licenses[WIP]/tools/gen-license-go/bin/windows/gen-license-go.exe b/archived/licenses[WIP]/tools/gen-license-go/bin/windows/gen-license-go.exe index f6c2a851..198e2830 100755 Binary files a/archived/licenses[WIP]/tools/gen-license-go/bin/windows/gen-license-go.exe and b/archived/licenses[WIP]/tools/gen-license-go/bin/windows/gen-license-go.exe differ diff --git a/archived/licenses[WIP]/tools/gen-license-go/cmd/gen.go b/archived/licenses[WIP]/tools/gen-license-go/cmd/gen.go index cce47eea..f3ac68c2 100644 --- a/archived/licenses[WIP]/tools/gen-license-go/cmd/gen.go +++ b/archived/licenses[WIP]/tools/gen-license-go/cmd/gen.go @@ -26,7 +26,7 @@ import ( ) var template string -var licensePathTemplate, icuPathTemplate = "licenses/%s.txt", "licenses/996.icu.template.%s.txt" +var licensePathTemplate, icuPathTemplate = "licenses/%s.txt", "licenses/templates/996.icu.template.%s.txt" // genCmd represents the gen command var genCmd = &cobra.Command{ @@ -72,6 +72,7 @@ gen-license-go gen mit --996icu en-us`, } func init() { + // Add the 'gen' sub-command into root-command. rootCmd.AddCommand(genCmd) // Here you will define your flags and configuration settings. diff --git a/archived/licenses[WIP]/tools/gen-license-go/cmd/root.go b/archived/licenses[WIP]/tools/gen-license-go/cmd/root.go index f9995667..342c101d 100644 --- a/archived/licenses[WIP]/tools/gen-license-go/cmd/root.go +++ b/archived/licenses[WIP]/tools/gen-license-go/cmd/root.go @@ -17,27 +17,16 @@ package cmd import ( - "fmt" "os" + "fmt" + "path" + "strings" + "io/ioutil" "github.com/spf13/cobra" ) -var LICENSES = []string{ - "agpl-3.0", - "apache-2.0", - "bsd-2-clause", - "bsd-3-clause", - "epl-2.0", - "gpl-2.0", - "gpl-3.0", - "lgpl-2.1", - "lgpl-3.0", - "mit", - "mpl-2.0", - "unlicenses", - "anti996icu-1.0", -} +var LICENSES []string // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ @@ -64,8 +53,17 @@ func Execute() { } func init() { - rootCmd.Flags().BoolP("list", "l", true, "list all licenses") - rootCmd.MarkFlagRequired("list") + // Read all filenames from licenses directory. + files, err := ioutil.ReadDir("./licenses") + handleError(err) + for _, file := range files { + if file.IsDir() { + continue + } else { + LICENSES = append(LICENSES, strings.TrimSuffix(file.Name(), path.Ext(file.Name()))) + } + } + // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, // will be global for your application. @@ -74,4 +72,6 @@ func init() { // Cobra also supports local flags, which will only run // when this action is called directly. // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + rootCmd.Flags().BoolP("list", "l", true, "list all licenses") + rootCmd.MarkFlagRequired("list") } diff --git a/archived/licenses[WIP]/tools/gen-license-go/licenses/996.icu.template.en-us.txt b/archived/licenses[WIP]/tools/gen-license-go/licenses/templates/996.icu.template.en-us.txt similarity index 100% rename from archived/licenses[WIP]/tools/gen-license-go/licenses/996.icu.template.en-us.txt rename to archived/licenses[WIP]/tools/gen-license-go/licenses/templates/996.icu.template.en-us.txt diff --git a/archived/licenses[WIP]/tools/gen-license-go/licenses/996.icu.template.zh-cn.txt b/archived/licenses[WIP]/tools/gen-license-go/licenses/templates/996.icu.template.zh-cn.txt similarity index 100% rename from archived/licenses[WIP]/tools/gen-license-go/licenses/996.icu.template.zh-cn.txt rename to archived/licenses[WIP]/tools/gen-license-go/licenses/templates/996.icu.template.zh-cn.txt