Initial rewriting
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
This commit is contained in:
44
flags.go_old
Normal file
44
flags.go_old
Normal file
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type intSlice []int
|
||||
type stringSlice []string
|
||||
|
||||
func (i *intSlice) String() string {
|
||||
return fmt.Sprintf("%d", *i)
|
||||
}
|
||||
|
||||
func (i *stringSlice) String() string {
|
||||
return fmt.Sprint(*i)
|
||||
}
|
||||
|
||||
func (i *intSlice) Set(value string) error {
|
||||
tmp, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
*i = append(*i, -1)
|
||||
} else {
|
||||
*i = append(*i, tmp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *stringSlice) Set(value string) error {
|
||||
*i = append(*i, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
func initFlags() (stringSlice, intSlice) {
|
||||
var tokens stringSlice
|
||||
var timeouts intSlice
|
||||
|
||||
flag.Var(&tokens, "t", "Bot token")
|
||||
flag.Var(&timeouts, "timeout", "Poller timeout in seconds")
|
||||
flag.Parse()
|
||||
|
||||
return tokens, timeouts
|
||||
}
|
Reference in New Issue
Block a user