link

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LinkAccountCmd = &cobra.Command{
		Use:   "link",
		Short: "create a local account by linking to an existing Signal account",
		Run: func(_ *cobra.Command, _ []string) {
			go common.Signald.Listen(nil)
			req := v1.GenerateLinkingURIRequest{}
			if testing {
				req.Server = signald.StagingServerUUID
			}

			response, err := req.Submit(common.Signald)
			if err != nil {
				log.Fatal(err)
			}
			switch common.OutputFormat {
			case common.OutputFormatJSON:
				err := json.NewEncoder(os.Stdout).Encode(response.Uri)
				if err != nil {
					log.Fatal(err, "error encoding response to stdout")
				}
			case common.OutputFormatYAML:
				err := yaml.NewEncoder(os.Stdout).Encode(response.Uri)
				if err != nil {
					log.Fatal(err, "error encoding response to stdout")
				}
			case common.OutputFormatCSV, common.OutputFormatTable:
				t := table.NewWriter()
				t.SetOutputMirror(os.Stdout)
				t.AppendHeader(table.Row{"URI"})
				t.AppendRow(table.Row{response.Uri})
				if common.OutputFormat == common.OutputFormatCSV {
					t.RenderCSV()
				} else {
					common.StylizeTable(t)
					t.Render()
				}
			case common.OutputFormatQR, common.OutputFormatDefault:
				qrterminal.Generate(response.Uri, qrterminal.M, os.Stdout)
			default:
				log.Fatal("unsupported output format")
			}

			finishReq := v1.FinishLinkRequest{
				DeviceName: deviceName,
				SessionId:  response.SessionId,
				Overwrite:  overwrite,
			}

			_, err = finishReq.Submit(common.Signald)

			if err != nil {
				log.Fatal(err)
			}
			log.Println("linking successful")
		},
	}
)

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