Skip to content

Commit e869536

Browse files
committed
add license command
1 parent c2c9eac commit e869536

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

cmd/license.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
const license = `
10+
Copyright © 2020 Blayne Campbell
11+
All rights reserved.
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions are met:
15+
16+
1. Redistributions of source code must retain the above copyright notice,
17+
this list of conditions and the following disclaimer.
18+
19+
2. Redistributions in binary form must reproduce the above copyright notice,
20+
this list of conditions and the following disclaimer in the documentation
21+
and/or other materials provided with the distribution.
22+
23+
3. Neither the name of the copyright holder nor the names of its contributors
24+
may be used to endorse or promote products derived from this software
25+
without specific prior written permission.
26+
27+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37+
POSSIBILITY OF SUCH DAMAGE.
38+
`
39+
40+
// listCmd represents the list command
41+
var licenseCmd = &cobra.Command{
42+
Use: "license",
43+
Short: "Display License",
44+
Long: `Display BSD 3 Clause License
45+
example:
46+
47+
rpda license
48+
49+
`,
50+
Run: func(cmd *cobra.Command, args []string) {
51+
fmt.Print(license)
52+
},
53+
}
54+
55+
func init() {
56+
rootCmd.AddCommand(licenseCmd)
57+
58+
// command flags and configuration settings.
59+
//
60+
}

cmd/root.go

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func init() {
119119

120120
// initConfig reads in config file and ENV variables if set.
121121
func initConfig() {
122+
// skip config setup when caller simply wants to display the license
123+
if os.Args[1] == "license" {
124+
return
125+
}
126+
122127
if cfgFile != "" {
123128
// Use config file from the flag.
124129
viper.SetConfigFile(cfgFile)

0 commit comments

Comments
 (0)