Adding custom license functionality

* Refactoring code that unnecessarily declares a map before making it.
* Cleaning up gpl3 formatting to match other licenses.
* Adding functionality that allows specifying custom license header
  and text in cobra config.
* Using license header and text as templates so that they can use
  template variables (for custom and gpl3 licenses).
* Adding ability to specify no license.
* Adding custom license example to README.
This commit is contained in:
Ian Walter
2016-03-31 14:31:03 -04:00
committed by Steve Francia
parent 3dc021e8c7
commit d811f40c6a
5 changed files with 80 additions and 48 deletions

View File

@ -226,13 +226,27 @@ The cobra generator will be easier to use if you provide a simple configuration
file which will help you eliminate providing a bunch of repeated information in
flags over and over.
an example ~/.cobra.yaml file:
An example ~/.cobra.yaml file:
```yaml
author: Steve Francia <spf@spf13.com>
license: MIT
```
You can specify no license by setting `license` to `none` or you can specify
a custom license:
```yaml
license:
header: This file is part of {{ .appName }}.
text: |
{{ .Copyright }}
This is my license. There are many like it, but this one is mine.
My license is my best friend. It is my life. I must master it as I must
master my life.
```
## Manually implementing Cobra
To manually implement cobra you need to create a bare main.go file and a RootCmd file.