Skip to content

B1NARY-GR0UP/nwa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NWA

Go Report Card

English | 中文

Mend Your Files

NWA

A More Powerful License Header Management Tool

Install

go install github.com/B1NARY-GR0UP/nwa@latest

Do not have a Go environment? Check the Docker section.

Usage

  • Add: Add license headers to files
  • Check: Check license headers of files
  • Remove: Remove licenses headers of files
  • Update: Update license headers of files
  • Config: Edit files according to the configuration file
  • Docker: Run NWA through docker, for those do not have a Go environment
  • Examples: Examples of NWA functionality
Usage:         
  nwa [command]

Common Mode Commands:
  add         add license headers to files
  check       check license headers of files
  remove      remove license headers of files
  update      update license headers of files

Config Mode Commands:
  config      edit the files according to the configuration file

Additional Commands:
  help        Help about any command

Flags:
  -h, --help      help for nwa
  -v, --version   version for nwa

Use "nwa [command] --help" for more information about a command.

Add - Add license headers to files

  • Usage
nwa add [flags] path...
  • Flags
Short Long Default Description
-c --copyright <COPYRIGHT HOLDER> copyright holder
-l --license apache license type
-i --spdxids "" SPDX IDs
-m --mute false (unspecified) mute mode
-s --skip [] skip file path
-t --tmpl "" template file path
-y --year time.Now().Year() (Current Year) copyright year
-h --help null help for add
  • Example
nwa add -l apache -c "RHINE LAB.LLC." -y 2077 ./server ./utils/bufferpool

Refer to nwa-examples for more examples.


Check - Check license headers of files

  • Usage
nwa check [flags] path...
  • Flags
Short Long Default Description
-c --copyright <COPYRIGHT HOLDER> copyright holder
-l --license apache license type
-i --spdxids "" SPDX IDs
-m --mute false (unspecified) mute mode
-s --skip [] skip file path
-t --tmpl "" template file path
-y --year time.Now().Year() (Current Year) copyright year
-h --help null help for check

NOTE: Do not use --mute (-m) flag with check command.

  • Example
nwa check --tmpl tmpl.txt ./client

Refer to nwa-examples for more examples.


Remove - Remove licenses headers of files

  • Usage
nwa remove [flags] path...
  • Flags
Short Long Default Description
-c --copyright <COPYRIGHT HOLDER> copyright holder
-l --license apache license type
-i --spdxids "" SPDX IDs
-m --mute false (unspecified) mute mode
-s --skip [] skip file path
-t --tmpl "" template file path
-y --year time.Now().Year() (Current Year) copyright year
-h --help null help for remove
  • Example
nwa remove -l mit -c "RHINE LAB.LLC." -s **.py pkg

Refer to nwa-examples for more examples.


Update - Update license headers of files

  • Usage
nwa update [flags] path...

NOTE: Update identifies the content before the first blank line as a license header; If your file does not meet the requirements, please use remove + add command.

  • Flags
Short Long Default Description
-c --copyright <COPYRIGHT HOLDER> copyright holder
-l --license apache license type
-i --spdxids "" SPDX IDs
-m --mute false (unspecified) mute mode
-s --skip [] skip file path
-t --tmpl "" template file path
-y --year time.Now().Year() (Current Year) copyright year
-h --help null help for update
  • Example
nwa update -l apache -c "BINARY Members" .

Refer to nwa-examples for more examples.


Config - Edit files according to the configuration file

  • Usage
nwa config [flags] path

NOTE: Path is the configuration file path.

  • Flags
Short Long Default Description
-h --help null help for config

NOTE: If some configuration are not configured, the default configuration will be used.

  • Example
nwa config config.yaml

Refer to nwa-examples for more examples.

  • Sample Configuration file

NOTE: If you set the tmpl field, the holder, year, license and spdxids fields will be ignored.

nwa:
  cmd: "add"                        # Default: "add" Optional: "add", "check", "remove", "update" 
  holder: "RHINE LAB.LLC."          # Default: "<COPYRIGHT HOLDER>"
  year: "2077"                      # Default: Current Year
  license: "apache"                 # Default: "apache"
  spdxids: ""                       # Default: ""
  mute: false                       # Default: false (unspecified)
  path: ["server", "client", "pkg"] # Default: []
  skip: ["**.py"]                   # Default: []
  tmpl: "nwa.txt"                   # Default: ""                                                       
  • Sample Template File
// Copyright 2077 RHINE LAB.LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

Docker - Run NWA through docker, for those do not have a Go environment

  • Install

Install the nwa docker image directly

EXAMPLE:

docker pull ghcr.io/b1nary-gr0up/nwa:main

OR

Build it from source

EXAMPLE:

docker build -t ghcr.io/b1nary-gr0up/nwa:main .
  • Verify if it can work correctly

EXAMPLE:

docker run -it ghcr.io/b1nary-gr0up/nwa:main --version
  • Mount the directory you want NWA to work with to /src and use the commands mentions in usage

EXAMPLE:

docker run -it -v ${PWD}:/src ghcr.io/b1nary-gr0up/nwa:main add -c "RHINE LAB.LLC." -y 2077 .

Related Projects

Blogs

Credits

Sincere appreciation to the following repositories that made the development of NWA possible.

License

NWA is distributed under the Apache License 2.0. The licenses of third party dependencies of NWA are explained here.

ECOLOGY

BMS

NWA is a Subproject of the Basic Middleware Service