Exemplo n.º 1
0
func main() {
	defer func() {
		if r := recover(); r != nil {
			fatal, ok := r.(*cmd.FatalError)
			if !ok {
				panic(r)
			}
			fmt.Println("ERROR:", fatal.Message)
			os.Exit(fatal.ReturnCode)
		}
	}()

	command := cmd.RootCommand()

	flags, args, err := command.ParseFlags(os.Args[1:])
	if err != nil {
		cmd.Fatal(err)
	}

	err = cmd.InitContext(flags)
	if err != nil {
		cmd.Fatal(err)
	}
	defer cmd.ShutdownContext()

	err = command.Dispatch(args)
	if err != nil {
		cmd.Fatal(err)
	}
}
Exemplo n.º 2
0
func main() {
	defer func() { os.Exit(returnCode) }()

	command := cmd.RootCommand()

	err := command.Flag.Parse(os.Args[1:])
	if err != nil {
		fatal(err)
		return
	}

	err = loadConfig(command)
	if err != nil {
		fatal(err)
		return
	}
	if returnCode != 0 {
		return
	}

	err = cmd.InitContext(command)
	if err != nil {
		fatal(err)
		return
	}
	defer cmd.ShutdownContext()

	err = command.Dispatch(command.Flag.Args())
	if err != nil {
		fatal(err)
		return
	}
}
Exemplo n.º 3
0
Arquivo: gen.go Projeto: liftup/aptly
func main() {
	command := cmd.RootCommand()
	command.UsageLine = "aptly"
	command.Dispatch(nil)

	_, _File, _, _ := runtime.Caller(0)
	_File, _ = filepath.Abs(_File)

	templ := template.New("man").Funcs(template.FuncMap{
		"allFlags":    allFlags,
		"findCommand": findCommand,
		"toUpper":     strings.ToUpper,
		"capitalize":  capitalize,
		"authors":     authors,
	})
	template.Must(templ.ParseFiles(filepath.Join(filepath.Dir(_File), "aptly.1.ronn.tmpl")))

	authorsF, err := os.Open(filepath.Join(filepath.Dir(_File), "..", "AUTHORS"))
	if err != nil {
		log.Fatal(err)
	}

	authorsB, err := ioutil.ReadAll(authorsF)
	if err != nil {
		log.Fatal(err)
	}

	authorsF.Close()

	authorsS = string(authorsB)

	output, err := os.Create(filepath.Join(filepath.Dir(_File), "aptly.1.ronn"))
	if err != nil {
		log.Fatal(err)
	}

	err = templ.ExecuteTemplate(output, "main", command)
	if err != nil {
		log.Fatal(err)
	}

	output.Close()

	out, err := exec.Command("ronn", filepath.Join(filepath.Dir(_File), "aptly.1.ronn")).CombinedOutput()
	if err != nil {
		os.Stdout.Write(out)
		log.Fatal(err)
	}

	cmd := exec.Command("man", filepath.Join(filepath.Dir(_File), "aptly.1"))
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err = cmd.Run()
	if err != nil {
		log.Fatal(err)
	}
}
Exemplo n.º 4
0
func main() {
	command := cmd.RootCommand()

	err := command.Flag.Parse(os.Args[1:])
	if err != nil {
		fatal(err)
	}

	err = loadConfig(command)
	if err != nil {
		fatal(err)
	}

	err = cmd.InitContext(command)
	if err != nil {
		fatal(err)
	}
	defer cmd.ShutdownContext()

	err = command.Dispatch(command.Flag.Args())
	if err != nil {
		fatal(err)
	}
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: liftup/aptly
func main() {
	os.Exit(cmd.Run(cmd.RootCommand(), os.Args[1:], true))
}