@@ -23,21 +23,21 @@ var (
23
23
binstdin = os .Stdin
24
24
)
25
25
26
- // Cat prints to or reads from STDIN/STDOUT
26
+ // Cat prints to or reads from STDIN/STDOUT.
27
27
func (s * Action ) Cat (c * cli.Context ) error {
28
28
ctx := ctxutil .WithGlobalFlags (c )
29
29
name := c .Args ().First ()
30
30
if name == "" {
31
31
return ExitError (ExitNoName , nil , "Usage: %s cat <NAME>" , c .App .Name )
32
32
}
33
33
34
- // handle pipe to stdin
34
+ // handle pipe to stdin.
35
35
info , err := binstdin .Stat ()
36
36
if err != nil {
37
37
return ExitError (ExitIO , err , "failed to stat stdin: %s" , err )
38
38
}
39
39
40
- // if content is piped to stdin, read and save it
40
+ // if content is piped to stdin, read and save it.
41
41
if info .Mode ()& os .ModeCharDevice == 0 {
42
42
debug .Log ("Reading from STDIN ..." )
43
43
content := & bytes.Buffer {}
@@ -78,14 +78,14 @@ func secFromBytes(dst, src string, in []byte) gopass.Secret {
78
78
return sec
79
79
}
80
80
81
- // BinaryCopy copies either from the filesystem to the store or from the store
82
- // to the filesystem
81
+ // BinaryCopy copies either from the filesystem to the store or from the store.
82
+ // to the filesystem.
83
83
func (s * Action ) BinaryCopy (c * cli.Context ) error {
84
84
ctx := ctxutil .WithGlobalFlags (c )
85
85
from := c .Args ().Get (0 )
86
86
to := c .Args ().Get (1 )
87
87
88
- // argument checking is in s.binaryCopy
88
+ // argument checking is in s.binaryCopy.
89
89
if err := s .binaryCopy (ctx , c , from , to , false ); err != nil {
90
90
return ExitError (ExitUnknown , err , "%s" , err )
91
91
}
@@ -94,25 +94,25 @@ func (s *Action) BinaryCopy(c *cli.Context) error {
94
94
95
95
// BinaryMove works like Copy but will remove (shred/wipe) the source
96
96
// after a successful copy. Mostly useful for securely moving secrets into
97
- // the store if they are no longer needed / wanted on disk afterwards
97
+ // the store if they are no longer needed / wanted on disk afterwards.
98
98
func (s * Action ) BinaryMove (c * cli.Context ) error {
99
99
ctx := ctxutil .WithGlobalFlags (c )
100
100
from := c .Args ().Get (0 )
101
101
to := c .Args ().Get (1 )
102
102
103
- // argument checking is in s.binaryCopy
103
+ // argument checking is in s.binaryCopy.
104
104
if err := s .binaryCopy (ctx , c , from , to , true ); err != nil {
105
105
return ExitError (ExitUnknown , err , "%s" , err )
106
106
}
107
107
return nil
108
108
}
109
109
110
110
// binaryCopy implements the control flow for copy and move. We support two
111
- // workflows:
112
- // 1. From the filesystem to the store
113
- // 2. From the store to the filesystem
111
+ // workflows:.
112
+ // 1. From the filesystem to the store.
113
+ // 2. From the store to the filesystem.
114
114
//
115
- // Copying secrets in the store must be done through the regular copy command
115
+ // Copying secrets in the store must be done through the regular copy command.
116
116
func (s * Action ) binaryCopy (ctx context.Context , c * cli.Context , from , to string , deleteSource bool ) error {
117
117
if from == "" || to == "" {
118
118
op := "copy"
@@ -124,10 +124,10 @@ func (s *Action) binaryCopy(ctx context.Context, c *cli.Context, from, to string
124
124
125
125
switch {
126
126
case fsutil .IsFile (from ) && fsutil .IsFile (to ):
127
- // copying from on file to another file is not supported
127
+ // copying from on file to another file is not supported.
128
128
return fmt .Errorf ("ambiguity detected. Only from or to can be a file" )
129
129
case s .Store .Exists (ctx , from ) && s .Store .Exists (ctx , to ):
130
- // copying from one secret to another secret is not supported
130
+ // copying from one secret to another secret is not supported.
131
131
return fmt .Errorf ("ambiguity detected. Either from or to must be a file" )
132
132
case fsutil .IsFile (from ) && ! fsutil .IsFile (to ):
133
133
return s .binaryCopyFromFileToStore (ctx , from , to , deleteSource )
@@ -139,11 +139,11 @@ func (s *Action) binaryCopy(ctx context.Context, c *cli.Context, from, to string
139
139
}
140
140
141
141
func (s * Action ) binaryCopyFromFileToStore (ctx context.Context , from , to string , deleteSource bool ) error {
142
- // if the source is a file the destination must no to avoid ambiguities
142
+ // if the source is a file the destination must not to avoid ambiguities.
143
143
// if necessary this can be resolved by using a absolute path for the file
144
- // and a relative one for the secret
144
+ // and a relative one for the secret.
145
145
146
- // copy from FS to store
146
+ // copy from FS to store.
147
147
buf , err := os .ReadFile (from )
148
148
if err != nil {
149
149
return fmt .Errorf ("failed to read file from %q: %w" , from , err )
@@ -159,7 +159,7 @@ func (s *Action) binaryCopyFromFileToStore(ctx context.Context, from, to string,
159
159
}
160
160
161
161
// it's important that we return if the validation fails, because
162
- // in that case we don't want to shred our (only) copy of this data!
162
+ // in that case we don't want to shred our (only) copy of this data!.
163
163
if err := s .binaryValidate (ctx , buf , to ); err != nil {
164
164
return fmt .Errorf ("failed to validate written data: %w" , err )
165
165
}
@@ -171,9 +171,9 @@ func (s *Action) binaryCopyFromFileToStore(ctx context.Context, from, to string,
171
171
172
172
func (s * Action ) binaryCopyFromStoreToFile (ctx context.Context , from , to string , deleteSource bool ) error {
173
173
// if the source is no file we assume it's a secret and to is a filename
174
- // (which may already exist or not)
174
+ // (which may already exist or not).
175
175
176
- // copy from store to FS
176
+ // copy from store to FS.
177
177
buf , err := s .binaryGet (ctx , from )
178
178
if err != nil {
179
179
return fmt .Errorf ("failed to read data from %q: %w" , from , err )
@@ -187,7 +187,7 @@ func (s *Action) binaryCopyFromStoreToFile(ctx context.Context, from, to string,
187
187
}
188
188
189
189
// as before: if validation of the written data fails, we MUST NOT
190
- // delete the (only) source
190
+ // delete the (only) source.
191
191
if err := s .binaryValidate (ctx , buf , from ); err != nil {
192
192
return fmt .Errorf ("failed to validate the written data: %w" , err )
193
193
}
@@ -238,7 +238,7 @@ func (s *Action) binaryGet(ctx context.Context, name string) ([]byte, error) {
238
238
return buf , nil
239
239
}
240
240
241
- // Sum decodes binary content and computes the SHA256 checksum
241
+ // Sum decodes binary content and computes the SHA256 checksum.
242
242
func (s * Action ) Sum (c * cli.Context ) error {
243
243
ctx := ctxutil .WithGlobalFlags (c )
244
244
name := c .Args ().First ()
0 commit comments