2022-01-04 21:41:41 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-01-06 21:29:02 +01:00
|
|
|
"log"
|
2022-01-05 18:38:52 +01:00
|
|
|
"os"
|
|
|
|
|
2022-01-21 15:36:31 +01:00
|
|
|
"github.com/syssecfsu/witty/web"
|
2022-01-04 21:41:41 +01:00
|
|
|
)
|
|
|
|
|
2022-01-05 03:21:21 +01:00
|
|
|
func main() {
|
2022-01-12 04:46:56 +01:00
|
|
|
fp, err := os.OpenFile("witty.log", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
2022-01-06 21:29:02 +01:00
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
defer fp.Close()
|
|
|
|
log.SetOutput(fp)
|
|
|
|
}
|
|
|
|
|
2022-01-07 02:21:11 +01:00
|
|
|
// parse the arguments. User can pass the command to execute
|
|
|
|
// by default, we use bash, but macos users might want to use zsh
|
|
|
|
// you can also run single program, such as pstree, htop...
|
|
|
|
// but program might misbehave (htop seems to be fine)
|
2022-01-21 15:36:31 +01:00
|
|
|
var cmdToExec = []string{"bash"}
|
2022-01-07 02:21:11 +01:00
|
|
|
args := os.Args
|
|
|
|
|
|
|
|
if len(args) > 1 {
|
2022-01-07 02:53:36 +01:00
|
|
|
cmdToExec = args[1:]
|
2022-01-07 02:21:11 +01:00
|
|
|
log.Println(cmdToExec)
|
|
|
|
}
|
|
|
|
|
2022-01-21 15:36:31 +01:00
|
|
|
web.StartWeb(fp, cmdToExec)
|
2022-01-05 03:21:21 +01:00
|
|
|
}
|