Version and Description in help output

This commit is contained in:
Aadi Desai 2024-01-15 00:58:16 +00:00
parent f4afdce578
commit 4bd33daafe
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
3 changed files with 26 additions and 6 deletions

View file

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Version flag for client and server binaries
- Description in help output of client and server binaries
### Changed
### Deprecated

View file

@ -73,6 +73,13 @@ type args struct {
Password *string `arg:"-p" help:"password, if required"`
}
func (a *args) Version() string {
return "v0.1.2"
}
func (a *args) Description() string {
return "Go, chat!\nA basic irc-style chat client, written in Go using bubbletea and websockets"
}
func main() {
ctx := context.Background()

View file

@ -41,15 +41,25 @@ type server struct {
nickm map[string]string
}
func main() {
log := log.New(os.Stderr, "ws server 🚀 ", log.LstdFlags|log.Lshortfile|log.Lmsgprefix)
var args struct {
type args struct {
Admin string `arg:"-a" default:"8bit" help:"admin user nick, allows access to /sudo" placeholder:"NICK"`
HistLen uint `arg:"-l" default:"10" help:"set message history size" placeholder:"N"`
Port uint `arg:"positional" default:"0" help:"port to listen on, random available port if not set"`
NickMap *string `arg:"-n" help:"path to nick:pass JSON file" placeholder:"FILE"`
}
func (a *args) Version() string {
return "v0.1.2"
}
func (a *args) Description() string {
return "Go, chat! Server\nA basic irc-style chat server, written in Go using websockets"
}
func main() {
log := log.New(os.Stderr, "ws server 🚀 ", log.LstdFlags|log.Lshortfile|log.Lmsgprefix)
var args args
arg.MustParse(&args)
nickMap, err := loadNickMap(args.NickMap)