mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	feat: fallback to default config on error loading user conf
This commit is contained in:
		
							parent
							
								
									3cb3b34023
								
							
						
					
					
						commit
						ef4975f984
					
				
							
								
								
									
										12
									
								
								lua.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lua.go
									
									
									
									
									
								
							| @ -10,6 +10,13 @@ import ( | |||||||
| 	"github.com/yuin/gopher-lua" | 	"github.com/yuin/gopher-lua" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | var minimalconf = ` | ||||||
|  | ansikit = require 'ansikit' | ||||||
|  | prompt(ansikit.text( | ||||||
|  | 		'{blue}%u {cyan}%d {green}∆{reset} ' | ||||||
|  | )) | ||||||
|  | ` | ||||||
|  | 
 | ||||||
| func LuaInit() { | func LuaInit() { | ||||||
| 	l = lua.NewState() | 	l = lua.NewState() | ||||||
| 
 | 
 | ||||||
| @ -56,7 +63,10 @@ func LuaInit() { | |||||||
| 	// Run config | 	// Run config | ||||||
| 	err = l.DoFile(homedir + "/.hilbishrc.lua") | 	err = l.DoFile(homedir + "/.hilbishrc.lua") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		fmt.Fprintln(os.Stderr, err, | ||||||
|  | 		"An error has occured while loading your config! Falling back to minimal default config.\n") | ||||||
|  | 
 | ||||||
|  | 		l.DoString(minimalconf) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user