This repository was archived by the owner on Feb 16, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ github.com/secrethub/demo-app v0.1.0 h1:HwPPxuiSvx4TBE7Qppzu3A9eHqmsBrIz4Ko8u8pq
7272github.com/secrethub/demo-app v0.1.0 /go.mod h1:ymjm8+WXTSDTFqsGVBNVmHSnwtZMYi7KptHvpo/fLH4 =
7373github.com/secrethub/secrethub-cli v0.30.0 /go.mod h1:dC0wd40v+iQdV83/0rUrOa01LYq+8Yj2AtJB1vzh2ao =
7474github.com/secrethub/secrethub-go v0.21.0 /go.mod h1:rc2IfKKBJ4L0wGec0u4XnF5/pe0FFPE4Q1MWfrFso7s =
75+ github.com/secrethub/secrethub-go v0.23.0 h1:6NzVGcAJDXeORUc2uZyuaYRCXCawmOKYvhNPP3ASNSM =
76+ github.com/secrethub/secrethub-go v0.23.0 /go.mod h1:rc2IfKKBJ4L0wGec0u4XnF5/pe0FFPE4Q1MWfrFso7s =
77+ github.com/secrethub/secrethub-go v0.23.1-0.20191114120141-797aba99690c h1:PJMNIc0Bq02IeCyZKMTxT8TaUDISwX0IAdbgOsfbdWQ =
78+ github.com/secrethub/secrethub-go v0.23.1-0.20191114120141-797aba99690c /go.mod h1:rc2IfKKBJ4L0wGec0u4XnF5/pe0FFPE4Q1MWfrFso7s =
7579github.com/secrethub/secrethub-go v0.23.1-0.20191202112815-8e4536fffb73 h1:TChbs2D26POGnhQ87QWCg17b3PQukTHPaxgGxAxxTgU =
7680github.com/secrethub/secrethub-go v0.23.1-0.20191202112815-8e4536fffb73 /go.mod h1:rc2IfKKBJ4L0wGec0u4XnF5/pe0FFPE4Q1MWfrFso7s =
7781github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4 =
Original file line number Diff line number Diff line change 1818type MkDirCommand struct {
1919 io ui.IO
2020 path api.DirPath
21+ parents bool
2122 newClient newClientFunc
2223}
2324
@@ -33,6 +34,7 @@ func NewMkDirCommand(io ui.IO, newClient newClientFunc) *MkDirCommand {
3334func (cmd * MkDirCommand ) Register (r command.Registerer ) {
3435 clause := r .Command ("mkdir" , "Create a new directory." )
3536 clause .Arg ("dir-path" , "The path to the directory" ).Required ().PlaceHolder (dirPathPlaceHolder ).SetValue (& cmd .path )
37+ clause .Flag ("parents" , "Create parent directories if needed. Does not error when directories already exist." ).BoolVar (& cmd .parents )
3638
3739 command .BindAction (clause , cmd .Run )
3840}
@@ -48,9 +50,16 @@ func (cmd *MkDirCommand) Run() error {
4850 return err
4951 }
5052
51- _ , err = client .Dirs ().Create (cmd .path .Value ())
52- if err != nil {
53- return err
53+ if cmd .parents {
54+ err = client .Dirs ().CreateAll (cmd .path .Value ())
55+ if err != nil {
56+ return err
57+ }
58+ } else {
59+ _ , err = client .Dirs ().Create (cmd .path .Value ())
60+ if err != nil {
61+ return err
62+ }
5463 }
5564
5665 fmt .Fprintf (cmd .io .Stdout (), "Created a new directory at %s\n " , cmd .path )
You can’t perform that action at this time.
0 commit comments