@@ -147,6 +147,10 @@ func loadPlugins() {
147
147
const pluginDesc = "Load the specified plugin by the full or relative path. " +
148
148
"Can be specified multiple times."
149
149
fs .Var (& pluginFlags , pluginFlagName , pluginDesc )
150
+ err := cobra .MarkFlagFilename (fs , "plugin" )
151
+ if err != nil {
152
+ panic (err )
153
+ }
150
154
pflag .Var (& pluginFlags , pluginFlagName , pluginDesc )
151
155
fs .Parse (os .Args [1 :])
152
156
for path := range pluginFlags {
@@ -168,17 +172,39 @@ targets can be added using the --plugin system.`,
168
172
Args : cobra .RangeArgs (1 , 2 ),
169
173
Run : func (cmd * cobra.Command , args []string ) {
170
174
flags := cmd .Flags ()
171
- firstParent , _ := flags .GetBool ("first-parent" )
172
- commitsFile , _ := flags .GetString ("commits" )
173
- protobuf , _ := flags .GetBool ("pb" )
174
- profile , _ := flags .GetBool ("profile" )
175
- disableStatus , _ := flags .GetBool ("quiet" )
176
- sshIdentity , _ := flags .GetString ("ssh-identity" )
175
+ getBool := func (name string ) bool {
176
+ value , err := flags .GetBool (name )
177
+ if err != nil {
178
+ panic (err )
179
+ }
180
+ return value
181
+ }
182
+ getString := func (name string ) string {
183
+ value , err := flags .GetString (name )
184
+ if err != nil {
185
+ panic (err )
186
+ }
187
+ return value
188
+ }
189
+ firstParent := getBool ("first-parent" )
190
+ commitsFile := getString ("commits" )
191
+ protobuf := getBool ("pb" )
192
+ profile := getBool ("profile" )
193
+ disableStatus := getBool ("quiet" )
194
+ sshIdentity := getString ("ssh-identity" )
177
195
178
196
if profile {
179
- go http .ListenAndServe ("localhost:6060" , nil )
197
+ go func () {
198
+ err := http .ListenAndServe ("localhost:6060" , nil )
199
+ if err != nil {
200
+ panic (err )
201
+ }
202
+ }()
180
203
prof , _ := os .Create ("hercules.pprof" )
181
- pprof .StartCPUProfile (prof )
204
+ err := pprof .StartCPUProfile (prof )
205
+ if err != nil {
206
+ panic (err )
207
+ }
182
208
defer pprof .StopCPUProfile ()
183
209
}
184
210
uri := args [0 ]
@@ -350,6 +376,7 @@ func formatUsage(c *cobra.Command) error {
350
376
leaves := hercules .Registry .GetLeaves ()
351
377
plumbing := hercules .Registry .GetPlumbingItems ()
352
378
features := hercules .Registry .GetFeaturedItems ()
379
+ hercules .EnablePathFlagTypeMasquerade ()
353
380
filter := map [string ]bool {}
354
381
for _ , l := range leaves {
355
382
filter [l .Flag ()] = true
@@ -450,20 +477,28 @@ var cmdlineDeployed map[string]*bool
450
477
451
478
func init () {
452
479
loadPlugins ()
453
- rootCmd .MarkFlagFilename ("plugin" )
454
480
rootFlags := rootCmd .Flags ()
455
481
rootFlags .String ("commits" , "" , "Path to the text file with the " +
456
- "commit history to follow instead of the default ` git log` . " +
482
+ "commit history to follow instead of the default ' git log' . " +
457
483
"The format is the list of hashes, each hash on a " +
458
484
"separate line. The first hash is the root." )
459
- rootCmd .MarkFlagFilename ("commits" )
485
+ err := rootCmd .MarkFlagFilename ("commits" )
486
+ if err != nil {
487
+ panic (err )
488
+ }
489
+ hercules .PathifyFlagValue (rootFlags .Lookup ("commits" ))
460
490
rootFlags .Bool ("first-parent" , false , "Follow only the first parent in the commit history - " +
461
491
"\" git log --first-parent\" ." )
462
492
rootFlags .Bool ("pb" , false , "The output format will be Protocol Buffers instead of YAML." )
463
493
rootFlags .Bool ("quiet" , ! terminal .IsTerminal (int (os .Stdin .Fd ())),
464
494
"Do not print status updates to stderr." )
465
495
rootFlags .Bool ("profile" , false , "Collect the profile to hercules.pprof." )
466
496
rootFlags .String ("ssh-identity" , "" , "Path to SSH identity file (e.g., ~/.ssh/id_rsa) to clone from an SSH remote." )
497
+ err = rootCmd .MarkFlagFilename ("ssh-identity" )
498
+ if err != nil {
499
+ panic (err )
500
+ }
501
+ hercules .PathifyFlagValue (rootFlags .Lookup ("ssh-identity" ))
467
502
cmdlineFacts , cmdlineDeployed = hercules .Registry .AddFlags (rootFlags )
468
503
rootCmd .SetUsageFunc (formatUsage )
469
504
rootCmd .AddCommand (versionCmd )
0 commit comments