mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 10:22:25 -05:00 
			
		
		
		
	Implement Cobra CLI tooling, Viper config tooling (#336)
* start pulling out + replacing urfave and config * replace many many instances of config * move more stuff => viper * properly remove urfave * move some flags to root command * add testrig commands to root * alias config file keys * start adding cli parsing tests * reorder viper init * remove config path alias * fmt * change config file keys to non-nested * we're more or less in business now * tidy up the common func * go fmt * get tests passing again * add note about the cliparsing tests * reorganize * update docs with changes * structure cmd dir better * rename + move some files around * fix dangling comma
This commit is contained in:
		
					parent
					
						
							
								182b4eea73
							
						
					
				
			
			
				commit
				
					
						0884f89431
					
				
			
		
					 487 changed files with 46667 additions and 8831 deletions
				
			
		
							
								
								
									
										94
									
								
								vendor/github.com/spf13/pflag/ip.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								vendor/github.com/spf13/pflag/ip.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,94 @@ | |||
| package pflag | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| // -- net.IP value | ||||
| type ipValue net.IP | ||||
| 
 | ||||
| func newIPValue(val net.IP, p *net.IP) *ipValue { | ||||
| 	*p = val | ||||
| 	return (*ipValue)(p) | ||||
| } | ||||
| 
 | ||||
| func (i *ipValue) String() string { return net.IP(*i).String() } | ||||
| func (i *ipValue) Set(s string) error { | ||||
| 	ip := net.ParseIP(strings.TrimSpace(s)) | ||||
| 	if ip == nil { | ||||
| 		return fmt.Errorf("failed to parse IP: %q", s) | ||||
| 	} | ||||
| 	*i = ipValue(ip) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (i *ipValue) Type() string { | ||||
| 	return "ip" | ||||
| } | ||||
| 
 | ||||
| func ipConv(sval string) (interface{}, error) { | ||||
| 	ip := net.ParseIP(sval) | ||||
| 	if ip != nil { | ||||
| 		return ip, nil | ||||
| 	} | ||||
| 	return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval) | ||||
| } | ||||
| 
 | ||||
| // GetIP return the net.IP value of a flag with the given name | ||||
| func (f *FlagSet) GetIP(name string) (net.IP, error) { | ||||
| 	val, err := f.getFlagType(name, "ip", ipConv) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return val.(net.IP), nil | ||||
| } | ||||
| 
 | ||||
| // IPVar defines an net.IP flag with specified name, default value, and usage string. | ||||
| // The argument p points to an net.IP variable in which to store the value of the flag. | ||||
| func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) { | ||||
| 	f.VarP(newIPValue(value, p), name, "", usage) | ||||
| } | ||||
| 
 | ||||
| // IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. | ||||
| func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { | ||||
| 	f.VarP(newIPValue(value, p), name, shorthand, usage) | ||||
| } | ||||
| 
 | ||||
| // IPVar defines an net.IP flag with specified name, default value, and usage string. | ||||
| // The argument p points to an net.IP variable in which to store the value of the flag. | ||||
| func IPVar(p *net.IP, name string, value net.IP, usage string) { | ||||
| 	CommandLine.VarP(newIPValue(value, p), name, "", usage) | ||||
| } | ||||
| 
 | ||||
| // IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. | ||||
| func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { | ||||
| 	CommandLine.VarP(newIPValue(value, p), name, shorthand, usage) | ||||
| } | ||||
| 
 | ||||
| // IP defines an net.IP flag with specified name, default value, and usage string. | ||||
| // The return value is the address of an net.IP variable that stores the value of the flag. | ||||
| func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP { | ||||
| 	p := new(net.IP) | ||||
| 	f.IPVarP(p, name, "", value, usage) | ||||
| 	return p | ||||
| } | ||||
| 
 | ||||
| // IPP is like IP, but accepts a shorthand letter that can be used after a single dash. | ||||
| func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP { | ||||
| 	p := new(net.IP) | ||||
| 	f.IPVarP(p, name, shorthand, value, usage) | ||||
| 	return p | ||||
| } | ||||
| 
 | ||||
| // IP defines an net.IP flag with specified name, default value, and usage string. | ||||
| // The return value is the address of an net.IP variable that stores the value of the flag. | ||||
| func IP(name string, value net.IP, usage string) *net.IP { | ||||
| 	return CommandLine.IPP(name, "", value, usage) | ||||
| } | ||||
| 
 | ||||
| // IPP is like IP, but accepts a shorthand letter that can be used after a single dash. | ||||
| func IPP(name, shorthand string, value net.IP, usage string) *net.IP { | ||||
| 	return CommandLine.IPP(name, shorthand, value, usage) | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue