当前位置: 首页>>代码示例>>Golang>>正文


Golang speakeasy.Ask函数代码示例

本文整理汇总了Golang中github.com/bgentry/speakeasy.Ask函数的典型用法代码示例。如果您正苦于以下问题:Golang Ask函数的具体用法?Golang Ask怎么用?Golang Ask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Ask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	cloudy, _ := ioutil.ReadFile("cloudy")
	if cloudy != nil {
		fmt.Println(string(cloudy))
	}

	login, err := speakeasy.Ask("enter your apple id: ")
	if err != nil {
		panic(err)
	}

	pass, err := speakeasy.Ask("enter your icloud pass: ")
	if err != nil {
		panic(err)
	}

	eng, err := engine.NewEngine(login, pass)
	if err != nil {
		panic(err)
	}

	fitems, cookie, token, err := drive.GetFolderItems(eng, "root")
	if err != nil {
		panic(err)
	}

	fitems_links, err := drive.GetFileItemsUrls(fitems, eng, cookie, token)
	if err != nil {
		panic(err)
	}
	fmt.Println("================================================================")
	fmt.Println("================================================================")
	fmt.Println("================================================================")
	for i := range fitems_links.Items {
		fmt.Println("name: ", fitems.Items[i].Name)
		fmt.Println("type: ", fitems.Items[i].Type)
		fmt.Println("url: ", fitems.Items[i].Url)
		fmt.Println("id: ", fitems.Items[i].Id)
	}

	/*
		iclouddrive, err2 := drive.NewD(eng)
		if err2 != nil {
			panic(err2)
		}

		fmt.Println(iclouddrive.Urls)

		if err := photos.PrintContent(total); err != nil {
			panic(err)
		}

			if err := photos.DownloadContent(total); err != nil {
				panic(err)
			}
	*/
}
开发者ID:lwsanty,项目名称:gophotocloud,代码行数:57,代码来源:icloud.go

示例2: walletloadseedcmd

// walletloadseedcmd adds a seed to the wallet's list of seeds
func walletloadseedcmd() {
	password, err := speakeasy.Ask("Wallet password: ")
	if err != nil {
		die("Reading password failed:", err)
	}
	seed, err := speakeasy.Ask("New Seed: ")
	if err != nil {
		die("Reading seed failed:", err)
	}
	qs := fmt.Sprintf("encryptionpassword=%s&seed=%s&dictionary=%s", password, seed, "english")
	err = post("/wallet/seed", qs)
	if err != nil {
		die("Could not add seed:", err)
	}
	fmt.Println("Added Key")
}
开发者ID:robvanmieghem,项目名称:Sia,代码行数:17,代码来源:walletcmd.go

示例3: actionUserPasswd

func actionUserPasswd(c *cli.Context) {
	api, user := mustUserAPIAndName(c)
	ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
	currentUser, err := api.GetUser(ctx, user)
	cancel()
	if currentUser == nil {
		fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(1)
	}
	pass, err := speakeasy.Ask("New password: ")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error reading password:", err)
		os.Exit(1)
	}

	ctx, cancel = context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
	_, err = api.ChangePassword(ctx, user, pass)
	cancel()
	if err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(1)
	}

	fmt.Printf("Password updated\n")
}
开发者ID:Celluliodio,项目名称:flannel,代码行数:25,代码来源:user_commands.go

示例4: preDecrypt

func preDecrypt(cmd *cobra.Command, args []string) {
	p := path.Dir(params.SettingsFile)
	diaryStore, err := ioutil.ReadFile(path.Join(p, "diary.md"))
	if err != nil {
		log.Printf("Unable to load stored diary")
		os.Exit(1)
	}
	tmp, err := ioutil.TempFile("", "diary")
	if err != nil {
		log.Printf("Unable to open a temp file")
		os.Exit(1)
	}
	tmpFile = tmp.Name()

	if set.Encrypt {
		pwd, err := speakeasy.Ask("Password: ")
		if err != nil {
			log.Printf("Unable to read password.")
			os.Exit(1)
		}
		tmpPass = pwd

		if len(diaryStore) > 0 {
			o := openssl.New()
			diaryStore, err = o.DecryptString(tmpPass, string(diaryStore))
			if err != nil {
				log.Printf("Unable to decrypt diary")
				os.Exit(1)
			}
		}
	}

	fmt.Fprintf(tmp, string(diaryStore))
	tmp.Close()
}
开发者ID:Luzifer,项目名称:diary,代码行数:35,代码来源:main.go

示例5: authCfgFromCmd

func authCfgFromCmd(cmd *cobra.Command) *authCfg {
	userFlag, err := cmd.Flags().GetString("user")
	if err != nil {
		ExitWithError(ExitBadArgs, err)
	}

	if userFlag == "" {
		return nil
	}

	var cfg authCfg

	splitted := strings.SplitN(userFlag, ":", 2)
	if len(splitted) < 2 {
		cfg.username = userFlag
		cfg.password, err = speakeasy.Ask("Password: ")
		if err != nil {
			ExitWithError(ExitError, err)
		}
	} else {
		cfg.username = splitted[0]
		cfg.password = splitted[1]
	}

	return &cfg
}
开发者ID:ringtail,项目名称:etcd,代码行数:26,代码来源:global.go

示例6: main

func main() {
	prog := os.Args[0]

	if len(os.Args) != 3 {
		usage(prog)
		os.Exit(1)
	}

	verb := os.Args[1]
	object := os.Args[2]

	password, err := speakeasy.Ask("Password: ")
	if err != nil {
		oopsie(err.Error())
	}

	switch verb {
	case "upload":
		upload(object, password)
	case "download":
		download(object, password)
	default:
		usage(prog)
		os.Exit(1)
	}
}
开发者ID:pakesson,项目名称:cfs,代码行数:26,代码来源:cfscli.go

示例7: apiGet

// apiGet wraps a GET request with a status code check, such that if the GET does
// not return 2xx, the error will be read and returned. The response body is
// not closed.
func apiGet(call string) (*http.Response, error) {
	if host, port, _ := net.SplitHostPort(addr); host == "" {
		addr = net.JoinHostPort("localhost", port)
	}
	resp, err := api.HttpGET("http://" + addr + call)
	if err != nil {
		return nil, errors.New("no response from daemon")
	}
	// check error code
	if resp.StatusCode == http.StatusUnauthorized {
		resp.Body.Close()
		// Prompt for password and retry request with authentication.
		password, err := speakeasy.Ask("API password: ")
		if err != nil {
			return nil, err
		}
		resp, err = api.HttpGETAuthenticated("http://"+addr+call, password)
		if err != nil {
			return nil, errors.New("no response from daemon - authentication failed")
		}
	}
	if resp.StatusCode == http.StatusNotFound {
		resp.Body.Close()
		return nil, errors.New("API call not recognized: " + call)
	}
	if non2xx(resp.StatusCode) {
		err := decodeError(resp)
		resp.Body.Close()
		return nil, err
	}
	return resp, nil
}
开发者ID:CSSZiegler,项目名称:Sia,代码行数:35,代码来源:main.go

示例8: populateCreds

func (l *login) populateCreds(e *env) error {
	if l.credentials.email != "" && l.credentials.password != "" {
		return nil
	}

	fmt.Fprint(e.Out, "Email: ")
	fmt.Fscanf(e.In, "%s\n", &l.credentials.email)

	var (
		password string
		err      error
	)
	if e.In == os.Stdin {
		password, err = speakeasy.Ask("Password (will be hidden): ")
		if err != nil {
			return err
		}
	} else {
		// NOTE: only for testing
		fmt.Fscanf(e.In, "%s\n", &password)
	}

	if password != "" {
		l.credentials.password = password
	}
	return nil
}
开发者ID:WilliamRen,项目名称:parse-cli,代码行数:27,代码来源:login.go

示例9: runLogin

func runLogin(cmd *Command, args []string) {
	var endpoint ForceEndpoint = EndpointProduction

	currentEndpoint, customUrl, err := CurrentEndpoint()
	if err == nil && &currentEndpoint != nil {
		endpoint = currentEndpoint
		if currentEndpoint == EndpointCustom && customUrl != "" {
			*instance = customUrl
		}
	}

	switch *instance {
	case "login":
		endpoint = EndpointProduction
	case "test":
		endpoint = EndpointTest
	case "pre":
		endpoint = EndpointPrerelease
	default:
		if *instance != "" {
			//need to determine the form of the endpoint
			uri, err := url.Parse(*instance)
			if err != nil {
				ErrorAndExit("no such endpoint: %s", *instance)
			}
			// Could be short hand?
			if uri.Host == "" {
				uri, err = url.Parse(fmt.Sprintf("https://%s", *instance))
				//fmt.Println(uri)
				if err != nil {
					ErrorAndExit("no such endpoint: %s", *instance)
				}
			}
			CustomEndpoint = uri.Scheme + "://" + uri.Host
			endpoint = EndpointCustom

			fmt.Println("Loaded Endpoint: (" + CustomEndpoint + ")")
		}
	}

	if len(*userName) != 0 { // Do SOAP login
		if len(*password) == 0 {
			var err error
			*password, err = speakeasy.Ask("Password: ")
			if err != nil {
				ErrorAndExit(err.Error())
			}
		}
		_, err := ForceLoginAndSaveSoap(endpoint, *userName, *password)
		if err != nil {
			ErrorAndExit(err.Error())
		}
	} else { // Do OAuth login
		_, err := ForceLoginAndSave(endpoint)
		if err != nil {
			ErrorAndExit(err.Error())
		}
	}
}
开发者ID:devangel,项目名称:force,代码行数:59,代码来源:login.go

示例10: readPassword

func readPassword(prompt string) (password string, err error) {
	if acceptPasswordFromStdin && !isTerminalIn {
		_, err = fmt.Scanln(&password)
		return
	}
	// NOTE: speakeasy may not support multi-byte chars on Windows
	return speakeasy.Ask("Enter password: ")
}
开发者ID:brianz,项目名称:empire,代码行数:8,代码来源:auth.go

示例11: getPassword

func getPassword(question string) string {
	password, err := speakeasy.Ask(fmt.Sprintf("%s", question))
	if err != nil {
		fmt.Printf("\nERROR: %s\n", err.Error())
		return getPassword(question)
	}
	return password
}
开发者ID:ContainX,项目名称:depcon,代码行数:8,代码来源:create_environment.go

示例12: main

func main() {
	password, err := speakeasy.Ask("Please enter a password: ")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Printf("Password result: %q\n", password)
	fmt.Printf("Password len: %d\n", len(password))
}
开发者ID:ChaitanyaRanade,项目名称:force,代码行数:9,代码来源:main.go

示例13: GetPassword

func (ctx *SecureContext) GetPassword() (string, error) {
	var password string
	var err error
	if password, err = speakeasy.Ask(DefaultPrompt); err != nil {
		return "", err
	}
	ctx.Password = password
	return ctx.Password, nil
}
开发者ID:rphillips,项目名称:gosec,代码行数:9,代码来源:gosec.go

示例14: FetchPassWord

func (cred *Credentials) FetchPassWord() {
	// Grab password
	password, err := speakeasy.Ask("Enter password: ")
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	cred.Password = password
}
开发者ID:amaniak,项目名称:tesla,代码行数:10,代码来源:credentials.go

示例15: main

func main() {
	var (
		secret string
		pin    string
		err    error
		nowStr string
		hash   string
	)

	secret, err = speakeasy.Ask("Secret (not echoed): ")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(2)
	}
	pin, err = speakeasy.Ask("PIN (not echoed): ")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(2)
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)

	go func() {
		for _ = range c {
			terminal.Stdout.Reset()
			os.Exit(3)
		}
	}()

	for {
		// 10-sec granularity
		nowStr = strconv.FormatInt(time.Now().Unix()/10, 10)

		hash = fmt.Sprintf("%x\n", md5.Sum([]byte(nowStr+secret+pin)))

		//fmt.Printf("OTP: %s\n", hash[:6])
		refresh("OTP", hash[:6])

		time.Sleep(10 * time.Second)
	}
}
开发者ID:marthjod,项目名称:scripts,代码行数:42,代码来源:motp_refresh.go


注:本文中的github.com/bgentry/speakeasy.Ask函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。