• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang speakeasy.Ask函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: loadPrivateKey

func loadPrivateKey(path string) (ssh.AuthMethod, error) {
	// Read file
	keyData, err := ioutil.ReadFile(path)
	if err != nil {
		log.Printf("error: could not read key file '%s': %s", path, err)
		return nil, err
	}

	// Get first PEM block
	block, _ := pem.Decode(keyData)
	if err != nil {
		log.Printf("error: no key found in file '%s': %s", path, err)
		return nil, err
	}

	// If it's encrypted...
	var (
		signer    ssh.Signer
		signerErr error
	)

	if x509.IsEncryptedPEMBlock(block) {
		// Get the passphrase
		prompt := fmt.Sprintf("Enter passphrase for key '%s': ", path)
		pass, err := speakeasy.Ask(prompt)
		if err != nil {
			log.Printf("error: error getting passphrase: %s", err)
			return nil, err
		}

		block.Bytes, err = x509.DecryptPEMBlock(block, []byte(pass))
		if err != nil {
			log.Printf("error: error decrypting key: %s", err)
			return nil, err
		}

		key, err := ParsePEMBlock(block)
		if err != nil {
			log.Printf("error: could not parse PEM block: %s", err)
			return nil, err
		}

		signer, signerErr = ssh.NewSignerFromKey(key)
	} else {
		signer, signerErr = ssh.ParsePrivateKey(keyData)
	}

	if signerErr != nil {
		log.Printf("error: error parsing private key '%s': %s", path, signerErr)
		return nil, signerErr
	}

	return ssh.PublicKeys(signer), nil
}
开发者ID:andrew-d,项目名称:rssh,代码行数:54,代码来源:main.go


示例17: walletloadsiagcmd

// walletloadsiagcmd loads a siag key set into the wallet.
func walletloadsiagcmd(keyfiles string) {
	password, err := speakeasy.Ask("Wallet password: ")
	if err != nil {
		die("Reading password failed:", err)
	}
	qs := fmt.Sprintf("keyfiles=%s&encryptionpassword=%s", keyfiles, password)
	err = post("/wallet/siagkey", qs)
	if err != nil {
		die("Loading siag key failed:", err)
	}
	fmt.Println("Wallet loading successful.")
}
开发者ID:robvanmieghem,项目名称:Sia,代码行数:13,代码来源:walletcmd.go


示例18: walletunlockcmd

// walletunlockcmd unlocks a saved wallet
func walletunlockcmd() {
	password, err := speakeasy.Ask("Wallet password: ")
	if err != nil {
		die("Reading password failed:", err)
	}
	qs := fmt.Sprintf("encryptionpassword=%s&dictonary=%s", password, "english")
	err = post("/wallet/unlock", qs)
	if err != nil {
		die("Could not unlock wallet:", err)
	}
	fmt.Println("Wallet unlocked")
}
开发者ID:zzmjohn,项目名称:Sia,代码行数:13,代码来源:walletcmd.go


示例19: getAccount

func getAccount(r io.Reader) (string, string, error) {
	scanner := bufio.NewScanner(r)
	for {
		fmt.Print("User: ")
		if scanner.Scan() {
			break
		}
	}
	username := scanner.Text()
	password, err := speakeasy.Ask("Password: ")
	return username, password, err
}
开发者ID:cad-san,项目名称:ikaring,代码行数:12,代码来源:ikaring.go


示例20: walletload033xcmd

// walletload033xcmd loads a v0.3.3.x wallet into the current wallet.
func walletload033xcmd(source string) {
	password, err := speakeasy.Ask("Wallet password: ")
	if err != nil {
		die("Reading password failed:", err)
	}
	qs := fmt.Sprintf("source=%s&encryptionpassword=%s", abs(source), password)
	err = post("/wallet/033x", qs)
	if err != nil {
		die("Loading wallet failed:", err)
	}
	fmt.Println("Wallet loading successful.")
}
开发者ID:robvanmieghem,项目名称:Sia,代码行数:13,代码来源:walletcmd.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang alphabet.Alphabet类代码示例发布时间:2022-05-24
下一篇:
Golang assert.NotNil函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap