passflag

package module
v0.0.0-...-85acde6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2013 License: MIT Imports: 2 Imported by: 0

README

passflag

Password flag for Go command line apps. Documentation online

passflag provides a silence, no echo'ed prompt that will ask for a password.

Install

go get github.com/fern4lvarez/passflag

##Usage

This is an example on how to use passflag on a command line app.

// GOPATH/src/pf_example/pf_example.go
package main

import (
  "flag"
  "fmt"
  "os"
  "github.com/fern4lvarez/passflag"
)

func main() {
  name := flag.String("name", "", "User name.")
  passflag.Password("p", true, "User Password.")
  flag.Parse()

  pw, _ := passflag.Get()
  fmt.Println("Name = ", *name)
  fmt.Println("Password = ", pw)
}

go get your example:

go get pf_example/pf_example.go

And try it on your terminal:

$ pf_example -name Foo -p
Password: (no echo)
Name =  Foo
Password = Bar

##License passflag is MIT licensed, see here

Documentation

Overview

passflag is a micropackage that provides a Password type flag. If the Password flag is used, a silence, no echo'ed prompt will ask for the password.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() (string, error)

Passflag will prompt a password input and returns the password introduced and an error if exists.

func Password

func Password(f string, def bool, des string) *bool

Password sets a password flag. It uses the same API format as the `flag` built-in package.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL