Пример #1
0
func main() {
	// dummy outside third party library
	cstore.NewManager("", "")

	fmt.Println("Hello golang!!")
	fmt.Printf("version: %s (%s) golang %s\n", version, hash, goversion)
}
Пример #2
0
func NewCStoreManager() (*cstore.Manager, error) {
	dirPath := GetRnzooDir()
	return cstore.NewManager("rnzoo", dirPath)
}
Пример #3
0
func main() {
	if show_usage {
		usage()
		os.Exit(0)
	}

	if show_version {
		showVersion()
		os.Exit(0)
	}

	err := opt.Validate()
	if err != nil {
		fmt.Printf("%s\n", err.Error())
		os.Exit(1)
	}

	m, err := cstore.NewManager("rnssh", getRnsshDir())
	if err != nil {
		fmt.Printf("can not create rnssh dir: %s\n", err.Error())
		os.Exit(1)
	}

	cs, err := m.New("config", cstore.TOML)
	if err != nil {
		fmt.Printf("%s\n", err.Error())
		os.Exit(1)
	}

	if initWizard {
		if err := DoConfigWizard(cs); err != nil {
			fmt.Println(err)
			os.Exit(1)
		} else {
			fmt.Println("saved rnssh config.")
			os.Exit(0)
		}
	}

	conf := Config{}
	err = cs.Get(&conf)
	if err != nil && !os.IsNotExist(err) {
		fmt.Printf("%s\n", err.Error())
		os.Exit(1)
	}

	rOpt := mergeConfig(&conf.Default, *opt)
	if !rOpt.UseSshConfig && rOpt.Region == "" {
		fmt.Println("region is empty. please specify by region option (-r) or set default region with --init option")
		os.Exit(1)
	}

	sshArgs, err := chooseAndGenSshArgs(rOpt, flag.Args(), m)
	if err != nil {
		fmt.Printf("%s\n", err.Error())
		os.Exit(1)
	}

	if showCommand {
		fmt.Printf("%s %s\n", "ssh", strings.Join(sshArgs, " "))
		os.Exit(0)
	}

	cmd := exec.Command("ssh", sshArgs...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Run()
}