Merge pull request #15494 from jmhbnz/txn_help_docs

Add detailed long description for etcdctl txn
This commit is contained in:
Benjamin Wang 2023-03-19 06:42:12 +08:00 committed by GitHub
commit 946918e4a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,30 @@ func NewTxnCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "txn [options]",
Short: "Txn processes all the requests in one transaction",
Run: txnCommandFunc,
Long: `Txn reads multiple etcd requests from standard input and applies them as a single atomic transaction.
A transaction consists of three components:
1) a list of conditions,
2) a list of requests to apply if all the conditions are true,
3) a list of requests to apply if any condition is false.
Example interactive stdin usage:
---
etcdctl txn -i
# compares:
mod("key1") > "0"
# success requests (get, put, delete):
put key1 "overwrote-key1"
# failure requests (get, put, delete):
put key1 "created-key1"
put key2 "some extra key"
---
Refer to https://github.com/etcd-io/etcd/blob/main/etcdctl/README.md#txn-options.`,
Run: txnCommandFunc,
}
cmd.Flags().BoolVarP(&txnInteractive, "interactive", "i", false, "Input transaction in interactive mode")
return cmd