Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 7ce492a

Browse files
author
Tuxx
committed
refactor: improve command-line help text formatting
- Consolidate flag variants in help output (e.g. -c, --config) - Use -- prefix for long form flags - Remove configuration examples from help text - Keep short form flags with - prefix - Maintain all existing flag functionality The help text is now more concise while preserving all command-line options.
1 parent 036d71b commit 7ce492a

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,28 @@ Lock your screen immediately:
153153
```bash
154154
fancylock -l
155155
# or
156-
fancylock -lock
156+
fancylock --lock
157157
```
158158

159159
Check version info:
160160

161161
```bash
162162
fancylock -v
163+
# or
164+
fancylock --version
163165
```
164166

167+
### Command-line Options
168+
169+
| Short | Long | Description |
170+
|-------|------|-------------|
171+
| `-c` | `--config` | Path to configuration file |
172+
| `-l` | `--lock` | Lock the screen immediately |
173+
| `-h` | `--help` | Display help information |
174+
| | `--debug-exit` | Enable exit with ESC or Q key (for debugging) |
175+
| | `--log` | Enable debug logging |
176+
| `-v` | `--version` | Show version info |
177+
165178
### Configuration
166179

167180
FancyLock looks for a configuration file at `~/.config/fancylock/config.json`. If it doesn't exist, a default one will be created.
@@ -170,6 +183,8 @@ You can specify a different configuration file using:
170183

171184
```bash
172185
fancylock -c /path/to/config.json
186+
# or
187+
fancylock --config /path/to/config.json
173188
```
174189

175190
### Sample Configuration

main.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
il "github.com/tuxx/fancylock/internal"
76
"log"
87
"os"
98
"path/filepath"
9+
10+
il "github.com/tuxx/fancylock/internal"
1011
)
1112

1213
func main() {
@@ -19,28 +20,26 @@ func main() {
1920

2021
helpFlag := flag.Bool("h", false, "Display help information")
2122
flag.BoolVar(helpFlag, "help", false, "Display help information")
22-
debugExit := flag.Bool("debug-exit", false, "Enable exit with ESC or Q key (for debugging)")
2323

24-
// Add debug mode flag
24+
debugExit := flag.Bool("debug-exit", false, "Enable exit with ESC or Q key (for debugging)")
2525
debugMode := flag.Bool("log", false, "Enable debug logging")
26-
2726
flagVersion := flag.Bool("v", false, "Show version info")
27+
flag.BoolVar(flagVersion, "version", false, "Show version info")
2828

2929
// Set custom usage output
3030
flag.Usage = func() {
3131
fmt.Fprintf(os.Stderr, "FancyLock: A media-playing screen locker\n\n")
3232
fmt.Fprintf(os.Stderr, "Usage: %s [options]\n\n", os.Args[0])
3333
fmt.Fprintf(os.Stderr, "Options:\n")
34-
flag.PrintDefaults()
34+
fmt.Fprintf(os.Stderr, " -c, --config string\n Path to configuration file\n")
35+
fmt.Fprintf(os.Stderr, " -l, --lock\n Lock the screen immediately\n")
36+
fmt.Fprintf(os.Stderr, " -h, --help\n Display help information\n")
37+
fmt.Fprintf(os.Stderr, " --debug-exit\n Enable exit with ESC or Q key (for debugging)\n")
38+
fmt.Fprintf(os.Stderr, " --log\n Enable debug logging\n")
39+
fmt.Fprintf(os.Stderr, " -v, --version\n Show version info\n")
3540
fmt.Fprintf(os.Stderr, "\nExamples:\n")
3641
fmt.Fprintf(os.Stderr, " %s -l # Lock screen immediately\n", os.Args[0])
3742
fmt.Fprintf(os.Stderr, " %s -c /path/to/config # Use specific config file\n", os.Args[0])
38-
fmt.Fprintf(os.Stderr, "\nConfiguration Options (in config.json):\n")
39-
fmt.Fprintf(os.Stderr, " pre_lock_command: Command to run before locking the screen\n")
40-
fmt.Fprintf(os.Stderr, " post_lock_command: Command to run after unlocking the screen\n")
41-
fmt.Fprintf(os.Stderr, "\nExample pre/post-lock commands:\n")
42-
fmt.Fprintf(os.Stderr, " pre_lock_command: \"notify-send 'Locking screen in 5 seconds' && sleep 5\"\n")
43-
fmt.Fprintf(os.Stderr, " post_lock_command: \"xset dpms force on && notify-send 'Welcome back!'\"\n")
4443
}
4544

4645
flag.Parse()

0 commit comments

Comments
 (0)