Add interactive flag
This commit is contained in:
parent
e310c168f4
commit
079214702a
10
main.go
10
main.go
|
@ -70,7 +70,7 @@ func initializeConfig(configPath, section string) *Config {
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
var configPath, section, serverAddress, user, password, to, cc, bcc, from, subject, text string
|
var configPath, section, serverAddress, user, password, to, cc, bcc, from, subject, text string
|
||||||
var encryption, dbg, versionFlag bool
|
var encryption, dbg, versionFlag, interactive bool
|
||||||
var serverPortAux int
|
var serverPortAux int
|
||||||
var serverPort int64
|
var serverPort int64
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ func main() {
|
||||||
flag.StringVar(&configPath, "conf", "", "Path to a config file (defaults to /etc/sendmail.toml)")
|
flag.StringVar(&configPath, "conf", "", "Path to a config file (defaults to /etc/sendmail.toml)")
|
||||||
flag.StringVar(§ion, "section", "default", "Section of the conf to read (defaults to \"default\")")
|
flag.StringVar(§ion, "section", "default", "Section of the conf to read (defaults to \"default\")")
|
||||||
flag.BoolVar(&dbg, "dbg", false, "Enable debugging output")
|
flag.BoolVar(&dbg, "dbg", false, "Enable debugging output")
|
||||||
|
flag.BoolVar(&interactive, "interactive", false, "Assume composing mail manually, do not timeout waiting input")
|
||||||
flag.StringVar(&serverAddress, "server-address", "", "The SMTP server address")
|
flag.StringVar(&serverAddress, "server-address", "", "The SMTP server address")
|
||||||
flag.IntVar(&serverPortAux, "server-port", 0, "The SMTP server")
|
flag.IntVar(&serverPortAux, "server-port", 0, "The SMTP server")
|
||||||
flag.BoolVar(&encryption, "force-ssl", false, "Force the use of ssl (defalut: false)")
|
flag.BoolVar(&encryption, "force-ssl", false, "Force the use of ssl (defalut: false)")
|
||||||
|
@ -104,14 +105,17 @@ func main() {
|
||||||
if flag.NArg() == 0 {
|
if flag.NArg() == 0 {
|
||||||
result := make(chan string, 1)
|
result := make(chan string, 1)
|
||||||
go readFromConsole(result)
|
go readFromConsole(result)
|
||||||
|
if interactive {
|
||||||
|
text = <-result
|
||||||
|
} else {
|
||||||
select {
|
select {
|
||||||
case text = <-result:
|
case text = <-result:
|
||||||
Info.Ln("text read from console")
|
Info.Ln("text read from console")
|
||||||
case <-time.After(5 * time.Minute):
|
case <-time.After(5 * time.Second):
|
||||||
Error.Ln("timeout reading from console")
|
Error.Ln("timeout reading from console")
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
text += fmt.Sprintf("%s\n", arg)
|
text += fmt.Sprintf("%s\n", arg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user