generate documentation and embed in binary

This commit is contained in:
Gokcehan committed 2016-09-14 00:40:14 +03:00
1 parent 57bebef804
commit 7d2ee16e2d
4 files changed
+125

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
//go:generate gen/docstring.sh
/*
lf is a terminal file manager.
Keys
Following commands along with the default keybindings are provided by lf.
up (default "k" and "<up>")
half-up (default "<c-u>")
page-up (default "<c-b>")
down (default "j" and "<down>")
half-down (default "<c-d>")
page-down (default "<c-f>")
updir (default "h" and "<left>")
open (default "l" and "<right>")
quit (default "q")
bot (default "G")
top (default "gg")
read (default ":")
read-shell (default "$")
read-shell-wait (default "!")
read-shell-async (default "&")
search (default "/")
search-back (default "?")
toggle (default "<space>")
yank (default "y")
delete (default "d")
paste (default "p")
renew (default "<c-l>")
Options
Following options can be used to customize the behavior of lf.
hidden bool (default off)
preview bool (default on)
scrolloff int (default 0)
tabstop int (default 8)
ifs string (default not set)
shell string (default $SHELL)
showinfo string (default none)
sortby string (default name)
ratios string (default 1:2:3)
Variables
Following variables are exported for shell commands.
$f current file
$fs marked file(s) (separated with ':')
$fx current file or marked file(s) if any
*/
package main
+55
View File
@@ -0,0 +1,55 @@
package main
var genDocString = `lf is a terminal file manager.
Keys
Following commands along with the default keybindings are provided by lf.
up (default "k" and "<up>")
half-up (default "<c-u>")
page-up (default "<c-b>")
down (default "j" and "<down>")
half-down (default "<c-d>")
page-down (default "<c-f>")
updir (default "h" and "<left>")
open (default "l" and "<right>")
quit (default "q")
bot (default "G")
top (default "gg")
read (default ":")
read-shell (default "$")
read-shell-wait (default "!")
read-shell-async (default "&")
search (default "/")
search-back (default "?")
toggle (default "<space>")
yank (default "y")
delete (default "d")
paste (default "p")
renew (default "<c-l>")
Options
Following options can be used to customize the behavior of lf.
hidden bool (default off)
preview bool (default on)
scrolloff int (default 0)
tabstop int (default 8)
ifs string (default not set)
shell string (default $SHELL)
showinfo string (default none)
sortby string (default name)
ratios string (default 1:2:3)
Variables
Following variables are exported for shell commands.
$f current file
$fs marked file(s) (separated with ':')
$fx current file or marked file(s) if any`
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Generates `docstring.go` having `genDocString` variable with `go doc` output.
#
# This script is called in `doc.go` using `go generate` to embed the
# documentation inside the binary in order to show it on request with `-doc`
# command line flag. Thus the same documentation is used for online and
# terminal display.
echo "package main\n\nvar genDocString = \`$(go doc)\`" > docstring.go
+6
View File
@@ -66,6 +66,7 @@ func startServer() {
} }
func main() { func main() {
showDoc := flag.Bool("doc", false, "show documentation")
serverMode := flag.Bool("server", false, "start server (automatic)") serverMode := flag.Bool("server", false, "start server (automatic)")
cpuprofile := flag.String("cpuprofile", "", "path to the file to write the cpu profile") cpuprofile := flag.String("cpuprofile", "", "path to the file to write the cpu profile")
flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)") flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
@@ -73,6 +74,11 @@ func main() {
flag.Parse() flag.Parse()
if *showDoc {
fmt.Println(genDocString)
return
}
if *cpuprofile != "" { if *cpuprofile != "" {
f, err := os.Create(*cpuprofile) f, err := os.Create(*cpuprofile)
if err != nil { if err != nil {