-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.go
More file actions
139 lines (112 loc) · 4.12 KB
/
help.go
File metadata and controls
139 lines (112 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package main
import (
"fmt"
"os"
"runtime"
)
// validFlags lists every command-line flag the application accepts.
// Keep this in sync with ShowHelp and the Determine*/CheckFor* functions.
var validFlags = map[string]bool{
"--help": true,
"-h": true,
"--init": true,
"--go-vim": true,
"--go-sqlite": true,
"--cgo-sqlite": true,
}
// ValidateArgs checks that every argument in args[1:] is a recognized flag.
// On the first unknown argument it prints an error and the help text to
// stderr, then exits with status 2.
func ValidateArgs(args []string) {
for _, arg := range args[1:] {
if !validFlags[arg] {
fmt.Fprintf(os.Stderr, "Error: unrecognized command-line argument %q\n\n", arg)
ShowHelp()
os.Exit(2)
}
}
}
const version = "0.1.0"
// ShowHelp displays the help message for vimango
func ShowHelp() {
helpText := `vimango - A vim-based note-taking application with SQLite storage
USAGE:
vimango [OPTIONS]
DESCRIPTION:
vimango is a terminal-based note-taking application that combines vim editing
capabilities with SQLite database storage. It supports full-text search, markdown
formatting, and an organizer interface for managing notes, contexts, folders, and
keywords.
OPTIONS:
--help, -h
Display this help message and exit
--init
Run first-time setup. Creates config.json with default settings and
initializes the SQLite databases (vimango.db and fts5_vimango.db).
Use this when running vimango for the first time after cloning.
--go-vim
Use the pure Go vim implementation (govim) instead of the CGO-based libvim.
Default: Uses libvim on Linux/Unix when available, govim on Windows or when
CGO is not available.
--go-sqlite
Use the pure Go SQLite driver (modernc.org/sqlite).
Default: This is already the default driver.
Note: Works on all platforms including Windows.
--cgo-sqlite
Use the CGO-based SQLite driver (github.com/mattn/go-sqlite3).
Requirements: Only available on Linux/Unix with CGO-enabled builds.
Note: Silently ignored on Windows or in pure Go builds.
EXAMPLES:
# First-time setup (creates config.json and databases)
./vimango --init
# Run with default settings (pure Go SQLite, libvim on Linux/CGO builds)
./vimango
# Run with pure Go vim implementation
./vimango --go-vim
# Run with CGO SQLite driver (requires CGO build)
./vimango --cgo-sqlite
# Combine multiple options
./vimango --go-vim --cgo-sqlite
BUILD INFORMATION:
Platform: %s
Architecture: %s
Go Version: %s
Linux/Unix Pure Go Build:
CGO_ENABLED=0 go build --tags=fts5
Linux/Unix with CGO (libvim, hunspell, sqlite3):
CGO_ENABLED=1 go build --tags="fts5,cgo"
Windows Cross-Compilation:
GOOS=windows GOARCH=amd64 go build --tags=fts5
PLATFORM-SPECIFIC BEHAVIOR:
Windows:
- Automatically uses pure Go implementations for vim and SQLite
- --cgo-sqlite flag is ignored (not available on Windows)
- Spell checking is not available (shows helpful message)
Linux/Unix:
- CGO builds support libvim, hunspell spell checking, and CGO SQLite
- Pure Go builds use govim and modernc.org/sqlite
- All features gracefully degrade when unavailable
FEATURES:
- Vim-based text editing with normal and insert modes
- SQLite database for note storage with FTS5 full-text search
- Organizer mode for browsing and managing notes
- Markdown support with preview and PDF export
- Context, folder, and keyword organization
- AI-powered deep research with web search and fetch
- WebView integration for in-app web browsing
- Spell checking (CGO builds only)
For more information, see the readme file in the project directory.
`
fmt.Printf(helpText, runtime.GOOS, runtime.GOARCH, runtime.Version())
}
// CheckForHelp checks if --help or -h flag is present in arguments
// Returns true if help was requested
func CheckForHelp(args []string) bool {
for _, arg := range args {
if arg == "--help" || arg == "-h" {
ShowHelp()
return true
}
}
return false
}