converge now uses flags for the command-line parsing.

This commit is contained in:
Erik Brakkee 2024-07-23 21:07:41 +02:00
parent ff1c13cc98
commit bc12d13c16
2 changed files with 24 additions and 4 deletions

View File

@ -21,4 +21,4 @@ COPY --from=builder /opt/converge/bin/agent \
/opt/converge/docs/
COPY --from=builder /opt/converge/static/ /opt/converge/docs/
ENTRYPOINT ["/opt/converge/bin/converge", "/opt/converge/docs" ]
ENTRYPOINT ["/opt/converge/bin/converge", "-docsdir", "/opt/converge/docs" ]

View File

@ -3,6 +3,7 @@ package main
import (
"converge/pkg/converge"
"converge/pkg/websocketutil"
"flag"
"fmt"
"log"
"net"
@ -26,11 +27,30 @@ func catchAllHandler(w http.ResponseWriter, r *http.Request) {
}
func main() {
downloadOption := flag.String("docsdir", "downloads",
"directory where documentation is located, either relative to current directory or an absolute path")
downloadDir := "downloads"
if len(os.Args) == 2 {
downloadDir = os.Args[1]
flag.Usage = func() {
fmt.Fprintln(os.Stderr, "Usage: converge [options]")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "Converge server is a rendez-vous server for debugging continuous integration")
fmt.Fprintln(os.Stderr, "jobs be providing the capability to log into the agents where jobs are running.")
fmt.Fprintln(os.Stderr, "This is achieve by starting an agent in the continuous integration job")
fmt.Fprintln(os.Stderr, "which connects to Converge using a websocket connection. The end user also connects")
fmt.Fprintln(os.Stderr, "to Converge using ssh over websockets. The server then matches the end-user with")
fmt.Fprintln(os.Stderr, "the agent running in the continous integration job (the rendez-vous) and sets up")
fmt.Fprintln(os.Stderr, "an end-to-end SSH connection between end-user and agent, with the agent providing")
fmt.Fprintln(os.Stderr, "an embedded SSH server to provide interactive access to the end-user. This works")
fmt.Fprintln(os.Stderr, "both on linux and on windows.")
fmt.Fprintln(os.Stderr)
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() != 0 {
flag.Usage()
os.Exit(1)
}
downloadDir := *downloadOption
log.Println("Doanload directory", downloadDir)
admin := converge.NewAdmin()