Skip to content

Commit

Permalink
docs: default configuration file specification
Browse files Browse the repository at this point in the history
  • Loading branch information
justlorain committed Jan 27, 2025
1 parent 67ecf60 commit 70af796
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,33 +203,36 @@ regardless of the previous license header.
- **Usage**

```shell
nwa config [flags] path
nwa config [flags] [path]
```

**NOTE: Path is the configuration file path.**
**NOTE: Path is the configuration file path. If not specified, `.nwa-config.yaml` will be used as the default configuration file path.**

- **Example**

```shell
nwa config config.yaml
nwa config -c check
```

The command in the example above reads the `config.yaml` **configuration file** and edits the license header of the specified files according to its content. The structure of the configuration file will be provided below.
The command in the example above reads the `.nwa-config.yaml` configuration file in the current directory
and checks whether the license headers of the specified files meet the requirements based on its content.

The structure of the configuration file will be provided below.

- **Sample Configuration file**

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

```yaml
nwa:
cmd: "add" # Default: "add" Optional: "add", "check", "remove", "update"
cmd: "add" # Default: "add" Optional: "add", "check", "remove", "update", can be overwritten by --command (-c) flag
holder: "RHINE LAB.LLC." # Default: "<COPYRIGHT HOLDER>"
year: "2077" # Default: Current Year
license: "apache" # Default: "apache"
spdxids: "" # Default: ""
mute: false # Default: false (unspecified)
verbose: false # Default: false (unspecified)
fuzzy: false # Default: false (unspecified)
fuzzy: false # Default: false (unspecified), only used for "check" command
path: ["server/**", "example/**"] # Default: []
skip: ["**.py"] # Default: []
tmpl: "nwa.txt" # Default: ""
Expand Down
14 changes: 8 additions & 6 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ var configCmd = &cobra.Command{
Short: "edit the files according to the configuration file",
Long: `Config Command | Edit files according to the configuration file
EXAMPLE: nwa config -c check config.yaml
EXAMPLE: nwa config -c check sample-config.yaml
NOTE: This command only supports the --command (-c) flag;
You can only specify the path of the configuration file, and everything depends on the configuration file.
If some configuration are not configured, the default configuration will be used.
NOTE: You can specify the path of the configuration file.
If not specified, .nwa-config.yaml will be used as the default configuration file path.
The behavior of NWA depends entirely on the configuration file.
If some configurations are not set, the default configurations will be used.
The command can also be set on the command line.
command priority:
The cmd field value can also be set by --command (-c) flag.
Priority:
1. --command (-c) flag
2. value configured for cmd in the configuration file
3. default value of cmd in the configuration file (add)
Expand Down

0 comments on commit 70af796

Please sign in to comment.