register.go raw

   1  package arg
   2  
   3  var registrations []interface{}
   4  
   5  // Register adds a struct that will be added to the command line arguments parsed
   6  // by any call to arg.Parse or arg.MustParse
   7  //
   8  // This allows you to have command line arguments defined per-package
   9  //
  10  //	package foo
  11  //
  12  //	var args struct {
  13  //		CacheSize int `arg:"--foo-cache-size"`
  14  //	}
  15  //
  16  //	func init() {
  17  //		arg.Register(&args)
  18  //	}
  19  func Register(dest any) {
  20  	registrations = append(registrations, dest)
  21  }
  22