mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "88d9f2e21df0145bc026ddf2567ac4dce89e2340" and "777d6ac4829a101a5adc6510e6b909ae6e013bcb" have entirely different histories.
88d9f2e21d
...
777d6ac482
4
go.mod
4
go.mod
|
@ -3,9 +3,11 @@ module hilbish
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4
|
||||||
|
github.com/akamensky/argparse v1.2.2
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||||
github.com/pborman/getopt v1.1.0
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
|
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
|
||||||
|
|
12
go.sum
12
go.sum
|
@ -1,3 +1,7 @@
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 h1:S9ulYwm5MUp02mEKnbDhVGjVBkdYV7/tmgEO1g3Q+Z8=
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4/go.mod h1:mp9I7lvFoZ3ldAeydCzISakl6VdQYyrR8vVjmnKGqDo=
|
||||||
|
github.com/akamensky/argparse v1.2.2 h1:P17T0ZjlUNJuWTPPJ2A5dM1wxarHgHqfYH+AZTo2xQA=
|
||||||
|
github.com/akamensky/argparse v1.2.2/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e h1:4G8AYOOwZdDWOiJR6D6JXaFmj5BDS7c5D5PyqsG/+Hg=
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e h1:4G8AYOOwZdDWOiJR6D6JXaFmj5BDS7c5D5PyqsG/+Hg=
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e/go.mod h1:fmqtV+Wqx0uFYLN1F4VhjZdtT56Dr8c3yA7nALFsw/Q=
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e/go.mod h1:fmqtV+Wqx0uFYLN1F4VhjZdtT56Dr8c3yA7nALFsw/Q=
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
||||||
|
@ -15,10 +19,13 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
|
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
||||||
github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
|
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
@ -33,6 +40,7 @@ golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
|
56
main.go
56
main.go
|
@ -10,13 +10,13 @@ import (
|
||||||
|
|
||||||
"hilbish/golibs/bait"
|
"hilbish/golibs/bait"
|
||||||
|
|
||||||
"github.com/pborman/getopt"
|
"github.com/akamensky/argparse"
|
||||||
"github.com/bobappleyard/readline"
|
"github.com/bobappleyard/readline"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4.0-dev.5"
|
const version = "0.4.0-dev.3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
l *lua.LState
|
l *lua.LState
|
||||||
|
@ -38,21 +38,44 @@ func main() {
|
||||||
homedir, _ = os.UserHomeDir()
|
homedir, _ = os.UserHomeDir()
|
||||||
defaultconfpath := homedir + "/.hilbishrc.lua"
|
defaultconfpath := homedir + "/.hilbishrc.lua"
|
||||||
|
|
||||||
// parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers")
|
parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers")
|
||||||
verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version")
|
verflag := parser.Flag("v", "version", &argparse.Options{
|
||||||
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")
|
Required: false,
|
||||||
cmdflag := getopt.StringLong("command", 'c', "", /*TODO: Help description*/ "")
|
Help: "Prints Hilbish version",
|
||||||
configflag := getopt.StringLong("config", 'C', defaultconfpath, "Sets the path to Hilbish's config")
|
})
|
||||||
|
setshflag := parser.Flag("S", "set-shell-env", &argparse.Options{
|
||||||
|
Required: false,
|
||||||
|
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{
|
||||||
|
Required: false,
|
||||||
|
Help: "Sets the path to Hilbish's config",
|
||||||
|
Default: defaultconfpath,
|
||||||
|
})
|
||||||
// loginshflag
|
// loginshflag
|
||||||
// TODO: issue #37
|
// TODO: issue #37
|
||||||
_ = getopt.BoolLong("login", 'l', "Makes Hilbish act like a login shell")
|
_ = parser.Flag("l", "login", &argparse.Options{
|
||||||
_ = getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
|
Required: false,
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
|
||||||
getopt.Parse()
|
err := parser.Parse(os.Args)
|
||||||
args := getopt.Args()
|
// If invalid flags or --help/-h,
|
||||||
interactiveflag := getopt.Lookup('i').Seen()
|
if err != nil {
|
||||||
|
// Print usage
|
||||||
|
fmt.Print(parser.Usage(err))
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if *cmdflag == "" || interactiveflag {
|
if *cmdflag == "" || *interactiveflag {
|
||||||
interactive = true
|
interactive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +120,6 @@ func main() {
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
|
||||||
RunInput(*cmdflag)
|
RunInput(*cmdflag)
|
||||||
if len(args) > 0 {
|
|
||||||
err := l.DoFile(args[0])
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintln(os.Stderr, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for interactive {
|
for interactive {
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
|
|
19
preload.lua
19
preload.lua
|
@ -65,22 +65,3 @@ do
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function additions to Lua standard library
|
|
||||||
function string.split(str, delimiter)
|
|
||||||
local result = {}
|
|
||||||
local from = 1
|
|
||||||
|
|
||||||
local delim_from, delim_to = string.find(str, delimiter, from)
|
|
||||||
|
|
||||||
while delim_from do
|
|
||||||
table.insert(result, string.sub(str, from, delim_from - 1))
|
|
||||||
from = delim_to + 1
|
|
||||||
delim_from, delim_to = string.find(str, delimiter, from)
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(result, string.sub(str, from))
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue