Initial commit
This commit is contained in:
		
							
								
								
									
										29
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
	"qurl/storage"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	dburl := flag.String("u", "bolt:./qurl.db", "url to database")
 | 
			
		||||
	jsonfile := flag.String("j", "", "path to json to load into database")
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	stor, err := storage.NewStorage(*dburl)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Fprintf(os.Stderr, "Database connection error: %s", err.Error())
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	defer stor.Shutdown()
 | 
			
		||||
 | 
			
		||||
	if *jsonfile != "" {
 | 
			
		||||
		err := loadjson(stor, *jsonfile)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Fprintf(os.Stderr, "Load error: %s", err.Error())
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user