cmd

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegisteredFrameworks = [...]common.ServeFramework{
	flowServe.NewFlowFramework(),
}
View Source
var ServeCmd = &cobra.Command{
	Use:   "serve",
	Short: "Wizard to be executed in source",
	Long: `The server part is run on the source / production system, where it automatically discovers used frameworks
and figures out what to extract.`,
	Example: `synco serve`,

	Run: func(cmd *cobra.Command, args []string) {
		sigs := make(chan os.Signal, 1)
		done := make(chan bool, 1)
		signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

		var err error
		if len(password) == 0 {
			password, err = util.GenerateRandomString(30)
			if err != nil {
				pterm.Fatal.Printfln("Error generating random password: %s", err)
			}
		}

		if len(identifier) == 0 {
			identifier, err = util.GenerateRandomString(7)
			if err != nil {
				pterm.Fatal.Printfln("Error generating identifier password: %s", err)
			}
		}

		progressbar, err := pterm.DefaultProgressbar.WithTotal(3).Start()
		pterm.PrintOnErrorf("Error initializing progress bar: %e", err)

		pterm.Debug.Printfln("Detecting Frameworks")

		for _, framework := range RegisteredFrameworks {
			progressbar.Add(1)
			pterm.Debug.Printfln("Checking for %s framework", framework.Name())
			if framework.Detect() {
				pterm.Info.Printfln("Found %s framework.", framework.Name())
				transferSession, err := serve.NewSession(identifier, password, listen, sigs)
				if err != nil {
					pterm.Fatal.Printfln("Error creating transfer session: %s", err)
				}

				framework.Serve(transferSession)
				pterm.Debug.Printfln("Waiting for ctrl-c")

				<-done
				return
			}
		}

		pterm.Error.Printfln("No frameworks could be detected. Aborting.")

		os.Exit(1)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL