help function
This commit is contained in:
		
							
								
								
									
										23
									
								
								envconf.go
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								envconf.go
									
									
									
									
									
								
							@@ -117,6 +117,29 @@ func (c *Config) Parse() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) Help() {
 | 
			
		||||
	max := 0
 | 
			
		||||
	for k, v := range c.env {
 | 
			
		||||
		if v.dtype != TypeNone {
 | 
			
		||||
			if len(k) > max {
 | 
			
		||||
				max = len(k)
 | 
			
		||||
			}
 | 
			
		||||
			if len(v.dtype.String()) > max {
 | 
			
		||||
				max = len(v.dtype.String())
 | 
			
		||||
			}
 | 
			
		||||
			if len(v.value) > max {
 | 
			
		||||
				max = len(v.value)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for k, v := range c.env {
 | 
			
		||||
		if v.dtype != TypeNone {
 | 
			
		||||
			format := fmt.Sprintf("Variable %%%ds|Type %%%ds|Default %%s\n", max, max)
 | 
			
		||||
			fmt.Printf(format, k, v.dtype, v.value)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Status prints out failures that occured while parsing the environment to os.Stderr.
 | 
			
		||||
// Variables that have been defined without a default value and are
 | 
			
		||||
// missing from the environment will be considered a failure.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user