示例#1
0
// NewWrite returns a Write configured to receive parameters from kingpin.
func NewWrite(c *kingpin.CmdClause) *Write {
	write := &Write{}
	write.keyID = c.Flag("key-id",
		"The ID of the key to use. If not set, we'll pick a key that is "+
			"already in use.").Short('k').String()
	write.name = c.Arg("name", "Name of the secret.").Required().String()
	write.value = c.Arg("value", "Value of the secret.").Required().String()

	clause := c.Flag("algorithm", "Encryption algorithm. Options: "+
		strings.Join(algorithms.GetAlgorithms(), ","))
	clause = clause.Short('a')
	clause = clause.Default(algorithms.GetDefaultAlgorithm())
	write.algo = clause.Enum(algorithms.GetAlgorithms()...)
	return write
}
示例#2
0
文件: put.go 项目: dcoker/secrets
// NewPut returns a Put configured to receive parameters from kingpin.
func NewPut(c *kingpin.CmdClause) *Put {
	write := &Put{}
	write.keyID = c.Flag("key-id",
		"The ID of the key to use. If not set, and if all values in the specified store are "+
			"using the same key ID, that key will be used.").Short('k').String()
	write.keyManager = c.Flag("key-manager", "Source of envelope encryption keys. Options: "+
		strings.Join(keymanager.GetKeyManagers(), ", ")).
		Default(keymanager.GetDefaultKeyManager()).Short('p').Enum(keymanager.GetKeyManagers()...)
	write.name = c.Arg("name", "Name of the secret.").Required().String()
	write.value = c.Arg("secret", "Value of the secret.").String()
	write.fromFile = c.Flag("from-file", "Read the secret from FILE instead "+
		"of the command line.").PlaceHolder("FILE").Short('i').File()
	write.algo = c.Flag("algorithm", "Encryption algorithm. Options: "+
		strings.Join(algorithms.GetAlgorithms(), ", ")).
		Short('a').
		Default(algorithms.GetDefaultAlgorithm()).
		Enum(algorithms.GetAlgorithms()...)

	return write
}