Skip to content

Commit

Permalink
docs: Add config file documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Mar 11, 2024
1 parent adba5d4 commit 17b8478
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ repos:
entry: go run ./internal/generate/docs
language: system
pass_filenames: false
- id: config-example
name: config-example
entry: go run ./internal/generate/config
language: system
types: [go]
pass_filenames: false
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ Womanhood6-Capsize-Zigzagged
Unwomanly-Unwashed1-Urchin
```
## Configuration
A configuration file will be generated the first time pwgen-go is run. Depending on your operating system, the file will be available at:
- **Windows:** `%AppData%\pwgen-go\config.toml`
- **macOS:** `~/Library/Application Support/pwgen-go/config.toml`
- **Linux:** `~/.config/pwgen-go/config.toml`
An example configuration is also available at [`config_example.toml`](config_example.toml).
## Templating
Templated passphrases are generated using Go's [text/template](https://pkg.go.dev/text/template) package.
Expand Down
6 changes: 6 additions & 0 deletions config_example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Number of passphrases to generate.
count = 10
# Template used to generate passphrases.
template = '{{ wordsWithNumber 3 | join "-" | title }}'
# Wordlist to use. (one of: long, short1, short2)
wordlist = 'long'
21 changes: 21 additions & 0 deletions internal/generate/config/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"os"

"github.com/gabe565/pwgen-go/internal/config"
"github.com/pelletier/go-toml/v2"
)

func main() {
f, err := os.Create("config_example.toml")
if err != nil {
panic(err)
}

encoder := toml.NewEncoder(f)
conf := config.NewDefault()
if err := encoder.Encode(conf); err != nil {
panic(err)
}
}

0 comments on commit 17b8478

Please sign in to comment.