Compare commits

..

10 Commits

Author SHA1 Message Date
TorchedSammy dc53eef829
ci: add checkout for create release 2022-03-12 22:32:32 -04:00
TorchedSammy 2f728de6a1
ci: fix checkout 2022-03-12 22:30:16 -04:00
TorchedSammy 4dc5ff60fd
ci: fix submodule clone 2022-03-12 22:22:15 -04:00
TorchedSammy a414c87e06
chore: bump version to v1.0.4 2022-03-12 22:15:31 -04:00
TorchedSammy b3db55708a
ci: clone submodules 2022-03-12 22:14:49 -04:00
TorchedSammy 7d7ccb5c9b
chore: prepare changelog for v1.0.4 2022-03-12 21:59:45 -04:00
TorchedSammy ece5f92307
fix: create history dir if it doesnt exist (fixes #113) 2022-03-12 21:50:57 -04:00
TorchedSammy 0e4f552be2
refactor: panic in history.go for more context 2022-03-12 21:43:02 -04:00
TorchedSammy 23902ea25c
chore: prepare for v1.0.3 release 2022-03-12 20:10:39 -04:00
TorchedSammy a7f0457dab
ci: include lua libs in release 2022-03-12 19:42:42 -04:00
6 changed files with 32 additions and 15 deletions

View File

@ -31,10 +31,12 @@ 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 docs emmyLuaDocs extra_files: LICENSE README.md CHANGELOG.md .hilbishrc.lua prelude libs docs emmyLuaDocs

View File

@ -1,5 +1,15 @@
# 🎀 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
@ -382,6 +392,8 @@ 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,11 +12,16 @@ type fileHistory struct {
f *os.File f *os.File
} }
func newFileHistory() (*fileHistory, error) { func newFileHistory() *fileHistory {
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) {
return nil, err panic(err)
} }
} }
@ -30,7 +35,7 @@ func newFileHistory() (*fileHistory, error) {
} }
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 {
return nil, err panic(err)
} }
fh := &fileHistory{ fh := &fileHistory{
@ -38,7 +43,7 @@ func newFileHistory() (*fileHistory, error) {
f: f, f: f,
} }
return fh, nil return fh
} }
func (h *fileHistory) Write(line string) (int, error) { func (h *fileHistory) Write(line string) (int, error) {

10
main.go
View File

@ -52,16 +52,18 @@ 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)
defaultConfPath = filepath.Join(confDir, "hilbish", "init.lua") defaultConfDir = filepath.Join(confDir, "hilbish")
} else { } else {
// else do ~ substitution // else do ~ substitution
defaultConfPath = filepath.Join(expandHome(defaultHistDir), "init.lua") defaultConfDir = expandHome(defaultHistDir)
} }
defaultConfPath = filepath.Join(defaultConfDir, "init.lua")
if defaultHistDir == "" { if defaultHistDir == "" {
defaultHistPath = filepath.Join(userDataDir, "hilbish", ".hilbish-history") defaultHistDir = filepath.Join(userDataDir, "hilbish")
} else { } else {
defaultHistPath = filepath.Join(expandHome(defaultHistDir), ".hilbish-history") defaultHistDir = expandHome(defaultHistDir)
} }
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,11 +20,7 @@ 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 {
fh, err := newFileHistory() fileHist = 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.2" version = "v1.0.4"
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'"