38 lines
		
	
	
		
			559 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			38 lines
		
	
	
		
			559 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								// Patial Tech.
							 | 
						||
| 
								 | 
							
								// Author, Ankit Patial
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								package main
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"flag"
							 | 
						||
| 
								 | 
							
									"fmt"
							 | 
						||
| 
								 | 
							
									"os"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const usageTxt = `Please provide output director and input schema.
							 | 
						||
| 
								 | 
							
								Example:
							 | 
						||
| 
								 | 
							
								  pgm/cmd -o ./db ./db/schema.sql
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								`
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func main() {
							 | 
						||
| 
								 | 
							
									var outDir string
							 | 
						||
| 
								 | 
							
									flag.StringVar(&outDir, "o", "", "-o as output directory path")
							 | 
						||
| 
								 | 
							
									flag.Parse()
							 | 
						||
| 
								 | 
							
									if len(os.Args) < 4 {
							 | 
						||
| 
								 | 
							
										fmt.Print(usageTxt)
							 | 
						||
| 
								 | 
							
										return
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									if outDir == "" {
							 | 
						||
| 
								 | 
							
										println("missing, -o output directory path")
							 | 
						||
| 
								 | 
							
										os.Exit(1)
							 | 
						||
| 
								 | 
							
										return
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									if err := generate(os.Args[3], outDir); err != nil {
							 | 
						||
| 
								 | 
							
										println(err.Error())
							 | 
						||
| 
								 | 
							
										os.Exit(1)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |