github.com/komosa/bug@v0.3.1/bug-import/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"strings"
     7  )
     8  
     9  func main() {
    10  	args := ArgumentList(os.Args)
    11  	if githubRepo := args.GetArgument("--github", ""); githubRepo != "" {
    12  		if strings.Count(githubRepo, "/") != 1 {
    13  			fmt.Fprintf(os.Stderr, "Invalid GitHub repo: %s\n", githubRepo)
    14  			os.Exit(2)
    15  		}
    16  		pieces := strings.Split(githubRepo, "/")
    17  		githubImport(pieces[0], pieces[1])
    18  
    19  	} else if args.GetArgument("--be", "") != "" {
    20  		beImport()
    21  	} else {
    22  		if strings.Count(githubRepo, "/") != 1 {
    23  			fmt.Fprintf(os.Stderr, "Usage: %s --github user/repo\n", os.Args[0])
    24  			fmt.Fprintf(os.Stderr, "       %s --be\n", os.Args[0])
    25  			fmt.Fprintf(os.Stderr, `
    26  Use this tool to import an external bug database into the local
    27  issues/ directory.
    28  
    29  Either "--github user/repo" is required to import GitHub issues,
    30  from GitHub, or "--be" is required to import a local BugsEverywhere
    31  database.
    32  `)
    33  			os.Exit(2)
    34  		}
    35  	}
    36  }