AddChild creates a new child Options that inherits from the current Options. If the current Options already has a child, it returns the existing child.
()
| 64 | // AddChild creates a new child Options that inherits from the current Options. |
| 65 | // If the current Options already has a child, it returns the existing child. |
| 66 | func (o *Options) AddChild() *Options { |
| 67 | if o.child != nil { |
| 68 | return o.child |
| 69 | } |
| 70 | |
| 71 | child := New() |
| 72 | child.main = o.Main() |
| 73 | o.child = child |
| 74 | |
| 75 | return child |
| 76 | } |
| 77 | |
| 78 | // Depth returns the depth of the Options in the hierarchy. |
| 79 | // The main Options has a depth of 0, its child has a depth of 1, and so on. |