@@ -161,6 +161,10 @@ func main() {
161161 Name : "user" ,
162162 Usage : "the user to run the command as" ,
163163 },
164+ cli.StringFlag {
165+ Name : "extract" ,
166+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
167+ },
164168 }, keyserviceFlags ... ),
165169 Action : func (c * cli.Context ) error {
166170 if c .NArg () != 2 {
@@ -178,6 +182,13 @@ func main() {
178182 if err != nil {
179183 return toExitError (err )
180184 }
185+
186+ extract , err := parseTreePath (c .String ("extract" ))
187+ if err != nil {
188+ return toExitError (err )
189+ // return common.NewExitError(fmt.Errorf("error parsing --extract path: %s", err), codes.InvalidTreePathFormat)
190+ }
191+
181192 opts := decryptOpts {
182193 OutputStore : & dotenv.Store {},
183194 InputStore : inputStore ,
@@ -186,6 +197,7 @@ func main() {
186197 KeyServices : svcs ,
187198 DecryptionOrder : order ,
188199 IgnoreMAC : c .Bool ("ignore-mac" ),
200+ Extract : extract ,
189201 }
190202
191203 if c .Bool ("background" ) {
@@ -239,6 +251,10 @@ func main() {
239251 Name : "filename" ,
240252 Usage : "filename for the temporarily file (default: tmp-file)" ,
241253 },
254+ cli.StringFlag {
255+ Name : "extract" ,
256+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
257+ },
242258 }, keyserviceFlags ... ),
243259 Action : func (c * cli.Context ) error {
244260 if c .NArg () != 2 {
@@ -251,6 +267,11 @@ func main() {
251267 inputStore := inputStore (c , fileName )
252268 outputStore := outputStore (c , fileName )
253269
270+ extract , err := parseTreePath (c .String ("extract" ))
271+ if err != nil {
272+ return common .NewExitError (fmt .Errorf ("error parsing --extract path: %s" , err ), codes .InvalidTreePathFormat )
273+ }
274+
254275 svcs := keyservices (c )
255276
256277 order , err := decryptionOrder (c .String ("decryption-order" ))
@@ -265,6 +286,7 @@ func main() {
265286 KeyServices : svcs ,
266287 DecryptionOrder : order ,
267288 IgnoreMAC : c .Bool ("ignore-mac" ),
289+ Extract : extract ,
268290 }
269291
270292 output , err := decrypt (opts )
@@ -680,7 +702,7 @@ func main() {
680702 },
681703 cli.StringFlag {
682704 Name : "extract" ,
683- Usage : "extract a specific key or branch from the input document. Decrypt mode only. Example: --extract '[\" somekey\" ][0]'" ,
705+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
684706 },
685707 cli.StringFlag {
686708 Name : "input-type" ,
0 commit comments