mirror of https://github.com/Hilbis/Hilbish
feat: -i (--interactive) and -c (--command) flag
parent
3862d2898c
commit
d4ecdd5ea0
1
lua.go
1
lua.go
|
@ -67,6 +67,7 @@ func LuaInit(confpath string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run config
|
// Run config
|
||||||
|
if !interactive { return }
|
||||||
err = l.DoFile(confpath)
|
err = l.DoFile(confpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err,
|
fmt.Fprintln(os.Stderr, err,
|
||||||
|
|
21
main.go
21
main.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4.0-dev.2"
|
const version = "0.4.0-dev.3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
l *lua.LState
|
l *lua.LState
|
||||||
|
@ -31,6 +31,7 @@ var (
|
||||||
bait hooks.Bait
|
bait hooks.Bait
|
||||||
homedir string
|
homedir string
|
||||||
running bool
|
running bool
|
||||||
|
interactive bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -46,6 +47,10 @@ func main() {
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Sets $SHELL to Hilbish's executed path",
|
Help: "Sets $SHELL to Hilbish's executed path",
|
||||||
})
|
})
|
||||||
|
cmdflag := parser.String("c", "command", &argparse.Options{
|
||||||
|
Required: false,
|
||||||
|
// TODO: Help: "",
|
||||||
|
})
|
||||||
configflag := parser.String("C", "config", &argparse.Options{
|
configflag := parser.String("C", "config", &argparse.Options{
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Sets the path to Hilbish's config",
|
Help: "Sets the path to Hilbish's config",
|
||||||
|
@ -57,7 +62,10 @@ func main() {
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Makes Hilbish act like a login shell",
|
Help: "Makes Hilbish act like a login shell",
|
||||||
})
|
})
|
||||||
|
interactiveflag := parser.Flag("i", "interactive", &argparse.Options{
|
||||||
|
Required: false,
|
||||||
|
Help: "Force Hilbish to be an interactive shell",
|
||||||
|
})
|
||||||
|
|
||||||
err := parser.Parse(os.Args)
|
err := parser.Parse(os.Args)
|
||||||
// If invalid flags or --help/-h,
|
// If invalid flags or --help/-h,
|
||||||
|
@ -67,6 +75,10 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *cmdflag == "" || *interactiveflag {
|
||||||
|
interactive = true
|
||||||
|
}
|
||||||
|
|
||||||
if *verflag {
|
if *verflag {
|
||||||
fmt.Printf("Hilbish v%s\n", version)
|
fmt.Printf("Hilbish v%s\n", version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -92,7 +104,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create it using either default config we found
|
// Create it using either default config we found
|
||||||
err = os.WriteFile(homedir+"/.hilbishrc.lua", input, 0644)
|
err = os.WriteFile(homedir + "/.hilbishrc.lua", input, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If that fails, bail
|
// If that fails, bail
|
||||||
fmt.Println("Error creating config file")
|
fmt.Println("Error creating config file")
|
||||||
|
@ -107,7 +119,8 @@ func main() {
|
||||||
readline.Completer = readline.FilenameCompleter
|
readline.Completer = readline.FilenameCompleter
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
|
||||||
for {
|
RunInput(*cmdflag)
|
||||||
|
for interactive {
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
input, err := readline.String(fmtPrompt())
|
input, err := readline.String(fmtPrompt())
|
||||||
|
|
Loading…
Reference in New Issue