ptk
Build your personal toolkit, write more, run in one tool!Why and How
- Write multiple tools, build all in one binary, stop toolA, toolB, toolC...!
- Parse plugins list, generate import and register code atomaticlly.
Ability
- Prefix match, one letter, one command
- Fully custom color
Concepts
All is plugin, put all your plugins underplugins
directory.Plugins are independent, doesn't depends on
ptk
, just like a normal go application, no complains here./main.go
/list.go # automatic generated
/plugins
/plugins/plugin1.go #
Plugin2
(main function)/plugins/plugin2
/plugins/plugin2/plugin2.go #
Main
(main function) Example
main.gopackage main
import (
"github.com/cosiner/ptk"
)
func main() {
ptk.App.Name = "mtk" // optional
ptk.App.Description = "personal toolkit!" // optional
ptk.Run()
}
// put your plugin description here, only first line will be used.
package plugins
import (
"flag"
"fmt"
)
func Hello() {
s := flag.String("s", "Hello World", "your string")
flag.Parse()
fmt.Println(*s)
}
// Package rand generate random string
package rand
import (
"flag"
"fmt"
"github.com/cosiner/gohper/crypto/rand"
"github.com/cosiner/gohper/errors"
)
func Main() {
n := flag.Int("n", 32, "bits number to generate")
flag.Parse()
s, err := rand.S.Alphabet(*n)
errors.Fatalln(err)
fmt.Println(s)
}
$ go build -o t
$ t build # if on windows, go build again
$ t hello -s "Hello guys"
$ t rand -n 64
from https://github.com/cosiner/ptk