Fix for - and file adding a route. Move null routes to their own issue.
Closes: #46
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@@ -40,6 +41,28 @@ func init() {
|
|||||||
entrypoint, _ := cmd.Flags().GetString("entrypoint")
|
entrypoint, _ := cmd.Flags().GetString("entrypoint")
|
||||||
urlPattern := args[0]
|
urlPattern := args[0]
|
||||||
|
|
||||||
|
if len(args) > 1 && command == "" {
|
||||||
|
commandFile := args[1]
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
if commandFile == "-" {
|
||||||
|
_, err := buf.ReadFrom(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file, err := os.Open(commandFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
_, err = buf.ReadFrom(file)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command = buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Read command from parameter, file or stdin
|
// TODO: Read command from parameter, file or stdin
|
||||||
if err := client.AddRoute(controlURL, urlPattern, method, entrypoint, command, os.Stdout); err != nil {
|
if err := client.AddRoute(controlURL, urlPattern, method, entrypoint, command, os.Stdout); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user