@@ -132,6 +132,10 @@ func main() {
132132 Name : "user" ,
133133 Usage : "the user to run the command as" ,
134134 },
135+ cli.StringFlag {
136+ Name : "extract" ,
137+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
138+ },
135139 }, keyserviceFlags ... ),
136140 Action : func (c * cli.Context ) error {
137141 if len (c .Args ()) != 2 {
@@ -144,13 +148,20 @@ func main() {
144148 inputStore := inputStore (c , fileName )
145149
146150 svcs := keyservices (c )
151+
152+ extract , err := parseTreePath (c .String ("extract" ))
153+ if err != nil {
154+ return common .NewExitError (fmt .Errorf ("error parsing --extract path: %s" , err ), codes .InvalidTreePathFormat )
155+ }
156+
147157 opts := decryptOpts {
148158 OutputStore : & dotenv.Store {},
149159 InputStore : inputStore ,
150160 InputPath : fileName ,
151161 Cipher : aes .NewCipher (),
152162 KeyServices : svcs ,
153163 IgnoreMAC : c .Bool ("ignore-mac" ),
164+ Extract : extract ,
154165 }
155166
156167 output , err := decrypt (opts )
@@ -199,6 +210,10 @@ func main() {
199210 Name : "filename" ,
200211 Usage : "filename for the temporarily file (default: tmp-file)" ,
201212 },
213+ cli.StringFlag {
214+ Name : "extract" ,
215+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
216+ },
202217 }, keyserviceFlags ... ),
203218 Action : func (c * cli.Context ) error {
204219 if len (c .Args ()) != 2 {
@@ -211,6 +226,11 @@ func main() {
211226 inputStore := inputStore (c , fileName )
212227 outputStore := outputStore (c , fileName )
213228
229+ extract , err := parseTreePath (c .String ("extract" ))
230+ if err != nil {
231+ return common .NewExitError (fmt .Errorf ("error parsing --extract path: %s" , err ), codes .InvalidTreePathFormat )
232+ }
233+
214234 svcs := keyservices (c )
215235 opts := decryptOpts {
216236 OutputStore : outputStore ,
@@ -219,6 +239,7 @@ func main() {
219239 Cipher : aes .NewCipher (),
220240 KeyServices : svcs ,
221241 IgnoreMAC : c .Bool ("ignore-mac" ),
242+ Extract : extract ,
222243 }
223244
224245 output , err := decrypt (opts )
@@ -592,7 +613,7 @@ func main() {
592613 },
593614 cli.StringFlag {
594615 Name : "extract" ,
595- Usage : "extract a specific key or branch from the input document. Decrypt mode only. Example: --extract '[\" somekey\" ][0]'" ,
616+ Usage : "extract a specific key or branch from the input document. Example: --extract '[\" somekey\" ][0]'" ,
596617 },
597618 cli.StringFlag {
598619 Name : "input-type" ,
0 commit comments