This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 3938d041bae1278c9ca8b693348cfa68f3aef7d6
Author: Hoshea <[email protected]>
AuthorDate: Mon Nov 23 20:11:41 2020 +0800

    dev
---
 README.md    | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 cmd/root.go  | 15 +++++++++++----
 main_test.go |  1 -
 3 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index b637500..e2b1381 100644
--- a/README.md
+++ b/README.md
@@ -5,14 +5,14 @@ A CLI tool for checking license headers, which theoretically 
supports checking a
 ## Install
 
 ```bash 
-git clone 
+git clone https://github.com/fgksgf/license-checker.git
 cd license-checker
 make
 ```
 
 ## Usage
 
-```bash
+```
 Usage: license-checker [flags]
 
 license-checker walks the specified path recursively and checks 
@@ -29,6 +29,52 @@ Flags:
   -v, --verbose         verbose mode
 ```
 
+## Configuration
+
+```json
+{
+  "licenseStrict": [
+    "Licensed to the Apache Software Foundation (ASF) under one or more",
+    "contributor license agreements.  See the NOTICE file distributed with",
+    "..."
+  ],
+  "licenseLoose": [
+    "Apache License, Version 2.0"
+  ],
+  "targetFiles": [
+    "java",
+    "go",
+    "py",
+    "sh",
+    "graphql",
+    "yaml",
+    "yml"
+  ],
+  "exclude": {
+    "files": [
+      ".gitignore",
+      "NOTICE",
+      "go.mod",
+      "go.sum",
+      ".DS_Store",
+      "LICENSE"
+    ],
+    "extensions": [
+      "md",
+      "xml",
+      "json"
+    ],
+    "directories": [
+      "bin",
+      ".github",
+      ".git",
+      ".idea",
+      "test"
+    ]
+  }
+}
+```
+
 ## Test
 
 ```bash
diff --git a/cmd/root.go b/cmd/root.go
index 84873e9..ef8abdf 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -28,10 +28,14 @@ import (
 )
 
 var (
-       cfgFile   string
+       // cfgFile is the path to the config file.
+       cfgFile string
+       // checkPath is the path to check license.
        checkPath string
-       loose     bool
-       verbose   bool
+       // loose is flag to enable loose mode.
+       loose bool
+       // verbose is flag to enable verbose mode.
+       verbose bool
 )
 
 // rootCmd represents the base command when called without any subcommands
@@ -53,7 +57,7 @@ if the specified files have the license header in the config 
file.`,
        },
 }
 
-// Execute adds all child commands to the root command and sets flags 
appropriately.
+// Execute sets flags to the root command appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
 func Execute() {
        rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", 
".licenserc.json", "the config file")
@@ -101,6 +105,7 @@ func LoadConfig() (*Config, error) {
        return &config, nil
 }
 
+// WalkAndCheck traverses the path p and check every target file's license.
 func WalkAndCheck(p string, cfg *Config) (*Result, error) {
        var license []string
        if loose {
@@ -149,6 +154,7 @@ func WalkAndCheck(p string, cfg *Config) (*Result, error) {
        return &result, err
 }
 
+// CheckLicense checks license of single file.
 func CheckLicense(filePath string, license []string) (bool, error) {
        file, err := os.Open(filePath)
        if err != nil {
@@ -171,6 +177,7 @@ func CheckLicense(filePath string, license []string) (bool, 
error) {
        return true, nil
 }
 
+// printResult prints license check result.
 func printResult(r *Result) {
        if verbose {
                for _, s := range r.Success {
diff --git a/main_test.go b/main_test.go
deleted file mode 100644
index 06ab7d0..0000000
--- a/main_test.go
+++ /dev/null
@@ -1 +0,0 @@
-package main

Reply via email to