示例#1
0
import (
	"errors"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"

	"github.com/alecthomas/kingpin"
)

var (
	timeout = kingpin.Flag("timeout", "Set connection timeout.").Short('t').Default("5s").Duration()
	headers = HTTPHeader(kingpin.Flag("headers", "Add HTTP headers to the request.").Short('H').PlaceHolder("HEADER=VALUE"))

	get         = kingpin.Command("get", "GET a resource.").Default()
	getFlag     = get.Flag("test", "Test flag").Bool()
	getURL      = get.Command("url", "Retrieve a URL.").Default()
	getURLURL   = getURL.Arg("url", "URL to GET.").Required().URL()
	getFile     = get.Command("file", "Retrieve a file.")
	getFileFile = getFile.Arg("file", "File to retrieve.").Required().ExistingFile()

	post           = kingpin.Command("post", "POST a resource.")
	postData       = post.Flag("data", "Key-value data to POST").Short('d').PlaceHolder("KEY:VALUE").StringMap()
	postBinaryFile = post.Flag("data-binary", "File with binary data to POST.").File()
	postURL        = post.Arg("url", "URL to POST to.").Required().URL()
)

type HTTPHeaderValue http.Header

func (h HTTPHeaderValue) Set(value string) error {
示例#2
0
/*
* miniLock-cli: A terminal utility to encrypt and decrypt files using the
* miniLock file encryption system
 */

import (
	"fmt"
	"github.com/alecthomas/kingpin"
	"github.com/cathalgarvey/go-minilock"
	"github.com/cathalgarvey/go-minilock/taber"
	"github.com/howeyc/gopass"
	"io/ioutil"
)

var (
	encrypt = kingpin.Command("encrypt", "Encrypt a file.")
	decrypt = kingpin.Command("decrypt", "Decrypt a file.")

	PassPhrase = kingpin.Flag("passphrase", "Full passphrase for this miniLock key. If not given through this flag, it will be asked for interactively").
			Short('p').String()
	OutputFileName = kingpin.Flag("output", "Name of output file. By default for encryption, this is input filename + '.minilock', and for decryption this is the indicated filename in the ciphertext. Warning: Right now this presents potential security hazards!").
			Short('o').Default("NOTGIVEN").String()

	efile = encrypt.Arg("file", "File to encrypt or decrypt.").Required().String()
	dfile = decrypt.Arg("file", "File to encrypt or decrypt.").Required().String()

	eUserEmail = encrypt.
			Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").
			Required().String()
	dUserEmail = decrypt.
			Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").