Compare commits

..

No commits in common. "dc53eef829710d5d347751c43a7ddf9e41e58471" and "4a4cb3409f20ee70f2ea726f6a2fb9a93bb847e1" have entirely different histories.

6 changed files with 15 additions and 32 deletions

View File

@ -31,12 +31,10 @@ jobs:
goos: windows goos: windows
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
submodules: recursive
- uses: wangyoucao577/go-release-action@v1.25 - uses: wangyoucao577/go-release-action@v1.25
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }} goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }} goarch: ${{ matrix.goarch }}
binary_name: hilbish binary_name: hilbish
extra_files: LICENSE README.md CHANGELOG.md .hilbishrc.lua prelude libs docs emmyLuaDocs extra_files: LICENSE README.md CHANGELOG.md .hilbishrc.lua prelude docs emmyLuaDocs

View File

@ -1,15 +1,5 @@
# 🎀 Changelog # 🎀 Changelog
## [1.0.4] - 2021-03-12
### Fixed
- Panic when history directory doesn't exist
## [1.0.3] - 2021-03-12
### Fixed
- Removed duplicate executable suggestions
- User input is added to history now instead of what's ran by Hilbish
- Formatting issue with prompt on no input
## [1.0.2] - 2021-03-06 ## [1.0.2] - 2021-03-06
### Fixed ### Fixed
- Cases where Hilbish's history directory doesn't exist will no longer cause a panic - Cases where Hilbish's history directory doesn't exist will no longer cause a panic
@ -392,8 +382,6 @@ This input for example will prompt for more input to complete:
First "stable" release of Hilbish. First "stable" release of Hilbish.
[1.0.4]: https://github.com/Rosettea/Hilbish/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/Rosettea/Hilbish/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/Rosettea/Hilbish/compare/v1.0.1...v1.0.2 [1.0.2]: https://github.com/Rosettea/Hilbish/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/Rosettea/Hilbish/compare/v1.0.0...v1.0.1 [1.0.1]: https://github.com/Rosettea/Hilbish/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/Rosettea/Hilbish/compare/v0.7.1...v1.0.0 [1.0.0]: https://github.com/Rosettea/Hilbish/compare/v0.7.1...v1.0.0

View File

@ -12,16 +12,11 @@ type fileHistory struct {
f *os.File f *os.File
} }
func newFileHistory() *fileHistory { func newFileHistory() (*fileHistory, error) {
err := os.MkdirAll(defaultHistDir, 0755)
if err != nil {
panic(err)
}
data, err := os.ReadFile(defaultHistPath) data, err := os.ReadFile(defaultHistPath)
if err != nil { if err != nil {
if !errors.Is(err, fs.ErrNotExist) { if !errors.Is(err, fs.ErrNotExist) {
panic(err) return nil, err
} }
} }
@ -35,7 +30,7 @@ func newFileHistory() *fileHistory {
} }
f, err := os.OpenFile(defaultHistPath, os.O_APPEND | os.O_WRONLY | os.O_CREATE, 0755) f, err := os.OpenFile(defaultHistPath, os.O_APPEND | os.O_WRONLY | os.O_CREATE, 0755)
if err != nil { if err != nil {
panic(err) return nil, err
} }
fh := &fileHistory{ fh := &fileHistory{
@ -43,7 +38,7 @@ func newFileHistory() *fileHistory {
f: f, f: f,
} }
return fh return fh, nil
} }
func (h *fileHistory) Write(line string) (int, error) { func (h *fileHistory) Write(line string) (int, error) {

10
main.go
View File

@ -52,18 +52,16 @@ func main() {
if defaultConfDir == "" { if defaultConfDir == "" {
// we'll add *our* default if its empty (wont be if its changed comptime) // we'll add *our* default if its empty (wont be if its changed comptime)
defaultConfDir = filepath.Join(confDir, "hilbish") defaultConfPath = filepath.Join(confDir, "hilbish", "init.lua")
} else { } else {
// else do ~ substitution // else do ~ substitution
defaultConfDir = expandHome(defaultHistDir) defaultConfPath = filepath.Join(expandHome(defaultHistDir), "init.lua")
} }
defaultConfPath = filepath.Join(defaultConfDir, "init.lua")
if defaultHistDir == "" { if defaultHistDir == "" {
defaultHistDir = filepath.Join(userDataDir, "hilbish") defaultHistPath = filepath.Join(userDataDir, "hilbish", ".hilbish-history")
} else { } else {
defaultHistDir = expandHome(defaultHistDir) defaultHistPath = filepath.Join(expandHome(defaultHistDir), ".hilbish-history")
} }
defaultHistPath = filepath.Join(defaultHistDir, ".hilbish-history")
helpflag := getopt.BoolLong("help", 'h', "Prints Hilbish flags") helpflag := getopt.BoolLong("help", 'h', "Prints Hilbish flags")
verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version") verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version")
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path") setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")

6
rl.go
View File

@ -20,7 +20,11 @@ func newLineReader(prompt string, noHist bool) *lineReader {
// we don't mind hilbish.read rl instances having completion, // we don't mind hilbish.read rl instances having completion,
// but it cant have shared history // but it cant have shared history
if !noHist { if !noHist {
fileHist = newFileHistory() fh, err := newFileHistory()
fileHist = fh // go stupid
if err != nil {
panic(err)
}
rl.SetHistoryCtrlR("file", fileHist) rl.SetHistoryCtrlR("file", fileHist)
rl.HistoryAutoWrite = false rl.HistoryAutoWrite = false
} }

View File

@ -2,7 +2,7 @@ package main
// String vars that are free to be changed at compile time // String vars that are free to be changed at compile time
var ( var (
version = "v1.0.4" version = "v1.0.2"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config defaultConfDir = "" // ~ will be substituted for home, path for user's default config
defaultHistDir = "" defaultHistDir = ""
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'" commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"