Skip to content

Commit

Permalink
Add detailed long description for etcdctl txn.
Browse files Browse the repository at this point in the history
Include an example stdin usage and a link for full docs.

Signed-off-by: James Blair <mail@jamesblair.net>
  • Loading branch information
jmhbnz committed Mar 16, 2023
1 parent f3587be commit 91a5f01
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion etcdctl/ctlv3/command/txn_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91a5f01

Please sign in to comment.