From 91a5f01a4e0075ec8889691c7d215af48273bc05 Mon Sep 17 00:00:00 2001 From: James Blair Date: Fri, 17 Mar 2023 11:38:56 +1300 Subject: [PATCH] Add detailed long description for etcdctl txn. Include an example stdin usage and a link for full docs. Signed-off-by: James Blair --- etcdctl/ctlv3/command/txn_command.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/etcdctl/ctlv3/command/txn_command.go b/etcdctl/ctlv3/command/txn_command.go index b05a7ea66..3efbab919 100644 --- a/etcdctl/ctlv3/command/txn_command.go +++ b/etcdctl/ctlv3/command/txn_command.go @@ -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