feat(console): added command to generate man pages
parent
06df2c21f0
commit
329e819e15
|
@ -26,3 +26,4 @@ gdb.txt
|
|||
|
||||
# Generated docs
|
||||
_docs/
|
||||
/man/
|
||||
|
|
|
@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* GitRepo: filter by repo
|
||||
* BuildLog: filter by start & end date, repo, exit code & arch
|
||||
* CLI flags to take advantage of above API improvements
|
||||
* Added CLI command to generate all man pages
|
||||
* PKGBUILDs now install man pages
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
5
Makefile
5
Makefile
|
@ -60,6 +60,11 @@ api-docs:
|
|||
rm -rf '$(SRC_DIR)/_docs'
|
||||
cd '$(SRC_DIR)' && v doc -all -f html -m -readme .
|
||||
|
||||
.PHONY: man
|
||||
man: vieter
|
||||
rm -rf man
|
||||
./vieter man man
|
||||
|
||||
|
||||
# =====OTHER=====
|
||||
.PHONY: lint
|
||||
|
|
3
PKGBUILD
3
PKGBUILD
|
@ -24,4 +24,7 @@ package() {
|
|||
|
||||
install -dm755 "$pkgdir/usr/bin"
|
||||
install -Dm755 "$pkgname/pvieter" "$pkgdir/usr/bin/vieter"
|
||||
|
||||
install -dm755 "$pkgdir/usr/share/man/man1"
|
||||
./vieter man "$pkgdir/usr/share/man/man1"
|
||||
}
|
||||
|
|
|
@ -32,4 +32,7 @@ package() {
|
|||
|
||||
install -dm755 "$pkgdir/usr/bin"
|
||||
install -Dm755 "$pkgname/pvieter" "$pkgdir/usr/bin/vieter"
|
||||
|
||||
install -dm755 "$pkgdir/usr/share/man/man1"
|
||||
./vieter man "$pkgdir/usr/share/man/man1"
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ module console
|
|||
|
||||
import arrays
|
||||
import strings
|
||||
import cli
|
||||
import os
|
||||
|
||||
// pretty_table converts a list of string data into a pretty table. Many thanks
|
||||
// to @hungrybluedev in the Vlang Discord for providing this code!
|
||||
|
@ -54,3 +56,15 @@ pub fn pretty_table(header []string, data [][]string) ?string {
|
|||
|
||||
return buffer.str()
|
||||
}
|
||||
|
||||
// export_man_pages recursively generates all man pages for the given
|
||||
// cli.Command & writes them to the given directory.
|
||||
pub fn export_man_pages(cmd cli.Command, path string) ? {
|
||||
man := cmd.manpage()
|
||||
os.write_file(os.join_path_single(path, cmd.full_name().replace(' ', '-') + '.1'),
|
||||
man)?
|
||||
|
||||
for sub_cmd in cmd.commands {
|
||||
export_man_pages(sub_cmd, path)?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module man
|
||||
|
||||
import cli
|
||||
import console
|
||||
import os
|
||||
|
||||
// cmd returns the cli submodule that handles generating man pages.
|
||||
pub fn cmd() cli.Command {
|
||||
return cli.Command{
|
||||
name: 'man'
|
||||
description: 'Generate all man pages & save them in the given directory.'
|
||||
usage: 'dir'
|
||||
required_args: 1
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
root := cmd.root()
|
||||
os.mkdir_all(cmd.args[0])?
|
||||
|
||||
console.export_man_pages(root, cmd.args[0])?
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import cli
|
|||
import console.git
|
||||
import console.logs
|
||||
import console.schedule
|
||||
import console.man
|
||||
import cron
|
||||
|
||||
fn main() {
|
||||
|
@ -29,6 +30,7 @@ fn main() {
|
|||
cron.cmd(),
|
||||
logs.cmd(),
|
||||
schedule.cmd(),
|
||||
man.cmd(),
|
||||
]
|
||||
}
|
||||
app.setup()
|
||||
|
|
Loading…
Reference in New Issue